#hash #sha #hashing #sha256 #sha1

streamsha

A streamed, resumable SHA (Secure Hashing Algorithm) library

2 releases (1 stable)

1.0.0 Sep 24, 2020
0.1.0 May 28, 2020

#6 in #sha

MIT license

29KB
766 lines


lib.rs:

StreamSha

Streamed, resumable Secure Hashing Algorithm(SHA) library

Example

# extern crate streamsha;
use streamsha::Sha256;
use streamsha::traits::{
  StreamHasher, Resumable
};
# fn main() {
// Simple hashing
let mut hasher = Sha256::new();
hasher.update(b"pien");
hasher.update(b"paon");
let hash1 = hasher.finish();

// Pause
let mut hasher1 = Sha256::new();
hasher1.update(b"pien");
let state1 = hasher1.pause();

// Resume on the other instance
let mut hasher2 = Sha256::resume(state1).unwrap();
hasher2.update(b"paon");
let hash2 = hasher2.finish();

assert_eq!(hash1, hash2);
# }

No runtime deps