feat: add util::digest_sha256
This commit is contained in:
12
src/util.rs
Normal file
12
src/util.rs
Normal file
@@ -0,0 +1,12 @@
|
||||
use sha2::{ Digest, Sha256 };
|
||||
|
||||
pub fn digest_sha256(bs: &[u8]) -> Vec<u8> {
|
||||
let mut sha256 = Sha256::new();
|
||||
sha256.update(bs);
|
||||
sha256.finalize().to_vec()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_digest_sha256() {
|
||||
assert_eq!(hex::decode("b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9").unwrap(), digest_sha256(b"hello world"));
|
||||
}
|
||||
Reference in New Issue
Block a user