Giter Club home page Giter Club logo

libmhash's Introduction

Description

A file hashing library that can do multiple hashes for multile files at the same time.

Supported hashes

CRC32, CRC32C, MD2, MD4, MD5, SHA1, SHA2, SHA3

Example

use libmhash::prelude::*;

fn main() {
    // create a hasher server
    let mut server = Builder::new()
        .on_result(Some(|r: &HasherResult<HasherTag>| println!("{:#?}", r)))
        .build()
        .unwrap();

    // use sender to send files or raw data
    let sender = server.data_sender();

    // you can also send files without spawning a new thread
    std::thread::spawn(move || {
        for entry in std::fs::read_dir(".").unwrap() {
            let dir = entry.unwrap();
            if dir.path().is_file() {
                // create hashers
                let mut hashers = vec![];

                // tags can be String or something else, but better choose something cheap to clone.
                hashers.push(HasherWrapper::new(
                    HasherTag::SHA1,
                    libmhash::paranoid_hash::SHA1::new(),
                ));

                // you can also create HasherWrapper from HasherTags
                hashers.push(HasherWrapper::create_from_tag(HasherTag::MD5));

                // send files
                sender.push_file(dir.path(), hashers);
            }
        }

        // don't forget to call end, otherwise the hasher server will keep waiting for new data.
        sender.end();
    });

    // do the computations, callbacks will be called in the same thread.
    server.compute();
}

libmhash's People

Contributors

maboroshinokiseki avatar

Stargazers

FNCS avatar Jeff Carpenter avatar

Watchers

 avatar

Forkers

sffej

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.