Function enc_file::get_sha2_512_hash
source · [−]Expand description
Get SHA2-512 Hash from data. File needs to be read as Vec
Examples
use enc_file::{get_sha2_512_hash, read_file};
//creating to different Vec<u8> to hash and compare
let test = b"Calculating the the SHA2-512 Hash of this text".to_vec();
let test2 = b"Calculating the SHA2-512 Hash of this different text".to_vec();
//hashing 2x test and 1x test2 to compare the hashes. hash1 == hash2 != hash3
let hash1 = get_sha2_512_hash(test.clone()).unwrap();
let hash2 = get_sha2_512_hash(test).unwrap();
let hash3 = get_sha2_512_hash(test2).unwrap();
assert_eq!(hash1, hash2);
assert_ne!(hash1, hash3);