8 stable releases

Uses old Rust 2015

2.0.3 Dec 27, 2020
2.0.2 Jun 6, 2020
2.0.1 Apr 22, 2020
2.0.0 Sep 16, 2017
1.0.1 Aug 19, 2016

#2051 in Algorithms

Download history 89/week @ 2024-07-19 76/week @ 2024-07-26 88/week @ 2024-08-02 189/week @ 2024-08-09 227/week @ 2024-08-16 231/week @ 2024-08-23 503/week @ 2024-08-30 287/week @ 2024-09-06 110/week @ 2024-09-13 143/week @ 2024-09-20 178/week @ 2024-09-27 246/week @ 2024-10-04 227/week @ 2024-10-11 450/week @ 2024-10-18 531/week @ 2024-10-25 470/week @ 2024-11-01

1,766 downloads per month
Used in 5 crates (via checksums)

MIT license

91KB
1.5K SLoC

C 1.5K SLoC // 0.4% comments Rust 136 SLoC

md6-rs TravisCI build status AppVeyorCI build status Licence

Implementation of the MD6 hash function for Rust via FFI.

Docs

Special thanks

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

  • ThePhD
  • Embark Studios

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.

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.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.

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)));

Special thanks

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

  • ThePhD
  • Embark Studios

Dependencies

~0.4–325KB