15 stable releases
1.4.0 | Aug 22, 2023 |
---|---|
1.2.2 | Jul 20, 2023 |
1.1.2 | Feb 10, 2023 |
1.1.1 | Oct 17, 2022 |
0.1.0 |
|
#20 in Cryptography
95,336 downloads per month
Used in 138 crates
(86 directly)
17KB
331 lines
sha256 crypto digest
Examples
sha256 digest function
use sha256::digest;
fn main() {
let input = "hello";
let val = digest(input);
assert_eq!(val, "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824");
let input = "hello".to_string();
let val = digest(input);
assert_eq!(val, "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824");
let input = b"hello";
let val = digest(input);
assert_eq!(val, "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824");
}
sha256 try_digest function
use sha256::try_digest;
use std::path::Path;
fn main() {
let input = Path::new("./foo.file");
let val = try_digest(input).unwrap();
assert_eq!(val,"433855b7d2b96c23a6f60e70c655eb4305e8806b682a9596a200642f947259b1");
}
Dependencies
~0.8–3MB
~60K SLoC