extendhash

crates.io docs.rs

extendhash is a Rust library to compute hash extensions. Currently only MD5 is supported, but more hash algorithms are planned in the future.

Usage

```rust use extendhash::md5;

let secretdata = "This is a secret!".asbytes(); let hash = md5::computehash(secretdata); let secretdatalength = secret_data.len();

// Now we try computing a hash extension, // assuming that secret_data is not available. // We only need hash and secret_data_length. let appendedmessage = "Appended message.".asbytes(); let combinedhash = md5::extendhash( hash, secretdatalength, appended_message);

// Now we verify that combined_hash matches the // concatenation (note the intermediate padding): let mut combineddata = Vec::::new(); combineddata.extendfromslice(secretdata); let intermediatepadding = md5::paddingforlength(secretdatalength); combineddata.extendfromslice(intermediatepadding.asslice()); combineddata.extendfromslice(appendedmessage); asserteq!(combinedhash, md5::computehash(combineddata.asslice())); ```

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.