easy-hasher

Easy hashing library for Rust

Hashing functions (all examples using SHA256): - String: sha256(&input)1 - File: file_sha256(&input)1 - Raw binary data: raw_sha256(input.clone())2


Supported algorithms:

File hashing is now supported!

Code examples:

String hash:

```rust extern crate easyhasher; use easyhasher::easy_hasher::*;

fn main() { let string = "example string".tostring(); let hash = sha256(&string); let stringhash = hash.tohexstring();

assert_eq!(string_hash,
           "aedfb92b3053a21a114f4f301a02a3c6ad5dff504d124dc2cee6117623eec706");
println!("SHA256({}) = {}", string, string_hash);

} ``` \ Raw data hash:

```rust extern crate easyhasher; use easyhasher::easy_hasher::*;

fn main() { let data = vec![0xA7, 0x34, 0x9F, 0x02]; // just random data lol let hash = rawsha256(data.clone()); let stringhash = hash.tohexstring();

assert_eq!(string_hash,
    "54dd1903dd45589e9f30e5cb4529d09417347cb27c2f478c7a9e33875917000c");
println!("SHA256({}) = {}", Hash::hex_string(&data), string_hash);

} ``` \ File hash:

```rust extern crate easyhasher; use easyhasher::easy_hasher::*;

fn main() { let path = getinput(); //some input function let file256 = filesha256(&path); let hash: Hash;

match file256 {
    Ok(h) => hash = h,
    Err(..) => abort()
}
println!("SHA256({}) = {}", path, hash.to_hex_string());

} ```


1: Passing by reference to avoid E0382 (borrow of moved value)
2: Using .clone() function for the same reason (and to simplify code)