#hashing #sha-256 #sha #sha-1 #hash

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

#2249 in Cryptography

MIT license

29KB
766 lines

StreamSha

Streamed, resumable Secure Hashing Algorithm(SHA) library

Example

use streamsha::Sha256;
use streamsha::traits::{
  StreamHasher, Resumable
};
// 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