refactor(utils): add hash verification functions
This commit is contained in:
parent
51722966e4
commit
6185a3123a
2 changed files with 16 additions and 7 deletions
12
src/utils.rs
12
src/utils.rs
|
|
@ -47,3 +47,15 @@ where
|
|||
|
||||
result
|
||||
}
|
||||
|
||||
pub fn verify_sha1(data: &[u8], expected_hex: &str) -> bool {
|
||||
let mut hasher = Sha1::new();
|
||||
hasher.update(data);
|
||||
hex::encode(hasher.finalize()) == expected_hex
|
||||
}
|
||||
|
||||
pub fn verify_sha512(data: &[u8], expected_hex: &str) -> bool {
|
||||
let mut hasher = Sha512::new();
|
||||
hasher.update(data);
|
||||
hex::encode(hasher.finalize()) == expected_hex
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue