extendhash

crates.io docs.rs

extendhash is a Rust library to compute hash extensions.

Supported hash algorithms:

Usage

```rust use extendhash::sha256;

let secretdata = "This is a secret!".asbytes(); let hash = sha256::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 = sha256::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 = sha256::paddingforlength(secretdatalength); combineddata.extendfromslice(intermediatepadding.asslice()); combineddata.extendfromslice(appendedmessage); asserteq!(combinedhash, sha256::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.