[][src]Crate md6

An implementation of the MD6 hash function, via FFI to reference implementation.

For more information about MD6 visit its official homepage.

There are two APIs provided: one for single-chunk hashing and one for hashing of multiple data segments.


Hashing a single chunk of data with a 256-bit MD6 hash function, then verifying the result.

let mut result = [0; 32];
md6::hash(256, b"The lazy fox jumps over the lazy dog", &mut result).unwrap();

assert_eq!(Vec::from_iter(result.iter().map(|&i| i)),
           vec![0xE4, 0x55, 0x51, 0xAA, 0xE2, 0x66, 0xE1, 0x48,
                0x2A, 0xC9, 0x8E, 0x24, 0x22, 0x9B, 0x3E, 0x90,
                0xDC, 0x06, 0x61, 0x77, 0xF8, 0xFB, 0x1A, 0x52,
                0x6E, 0x9D, 0xA2, 0xCC, 0x95, 0x71, 0x97, 0xAA]);

Hashing multiple chunks of data with a 512-bit MD6 hash function, then verifying the result.

let mut result = [0; 64];
let mut state = Md6::new(512).unwrap();

state.update("Zażółć ".as_bytes());
state.update("gęślą ".as_bytes());

state.finalise(&mut result);
assert_eq!(Vec::from_iter(result.iter().map(|&i| i)),
           vec![0x92, 0x4E, 0x91, 0x6A, 0x01, 0x2C, 0x1A, 0x8D,
                0x0F, 0xB7, 0x9A, 0x4A, 0xD4, 0x9C, 0x55, 0x5E,
                0xBD, 0xCA, 0x59, 0xB8, 0x1B, 0x4C, 0x13, 0x41,
                0x2E, 0x32, 0xA5, 0xC9, 0x3B, 0x61, 0xAD, 0xB8,
                0x4D, 0xB3, 0xF9, 0x0C, 0x03, 0x51, 0xB2, 0x9E,
                0x7B, 0xAE, 0x46, 0x9F, 0x8D, 0x60, 0x5D, 0xED,
                0xFF, 0x51, 0x72, 0xDE, 0xA1, 0x6F, 0x00, 0xF7,
                0xB4, 0x82, 0xEF, 0x87, 0xED, 0x77, 0xD9, 0x1A]);

Comparing result of single- and multi-chunk hash methods hashing the same effective message with a 64-bit MD6 hash function.

let mut result_multi  = [0; 8];
let mut result_single = [0; 8];

let mut state = Md6::new(64).unwrap();
state.update("Zażółć ".as_bytes());
state.update("gęślą ".as_bytes());
state.finalise(&mut result_multi);

md6::hash(64, "Zażółć gęślą jaźń".as_bytes(), &mut result_single).unwrap();

assert_eq!(Vec::from_iter(result_multi .iter().map(|&i| i)),
           Vec::from_iter(result_single.iter().map(|&i| i)));

Special thanks

To all who support further development on Patreon, in particular:



Hashing state for multiple data sets.



Some functions in the library can fail, this enum represents all the possible ways they can.



Hash all data in one fell swoop.

Type Definitions


Helper result type containing Md6Error.