5 stable releases

2.0.0 Sep 16, 2017
1.1.1 Jan 20, 2017
1.1.0 Jan 1, 2017
1.0.1 Aug 19, 2016

#351 in Algorithms

Download history 97/week @ 2019-12-14 56/week @ 2019-12-21 80/week @ 2019-12-28 115/week @ 2020-01-04 107/week @ 2020-01-11 144/week @ 2020-01-18 70/week @ 2020-01-25 148/week @ 2020-02-01 77/week @ 2020-02-08 124/week @ 2020-02-15 114/week @ 2020-02-22 77/week @ 2020-02-29 118/week @ 2020-03-07 80/week @ 2020-03-14 84/week @ 2020-03-21 101/week @ 2020-03-28

522 downloads per month
Used in 3 crates (2 directly)

MIT license

88KB
1.5K SLoC

C 1.5K SLoC // 0.3% comments Rust 109 SLoC // 0.7% comments

md6-rs TravisCI build status AppVeyorCI build status Licence Crates.io version

Implementation of the MD6 hash function for Rust via FFI.

Docs


lib.rs:

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.

Examples

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

# use md6::Md6;
# use std::iter::FromIterator;
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.

# use md6::Md6;
# use std::iter::FromIterator;
let mut result = [0; 64];
let mut state = Md6::new(512).unwrap();

state.update("Zażółć ".as_bytes());
state.update("gęślą ".as_bytes());
state.update("jaźń".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.

# use md6::Md6;
# use std::iter::FromIterator;
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.update("jaźń".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)));

Dependencies