diff options
Diffstat (limited to 'src/util/sha1.rs')
| -rw-r--r-- | src/util/sha1.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/util/sha1.rs b/src/util/sha1.rs new file mode 100644 index 0000000..c5f1021 --- /dev/null +++ b/src/util/sha1.rs | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | #![allow(dead_code)] | ||
| 2 | |||
| 3 | use std::path::Path; | ||
| 4 | |||
| 5 | use sha1::{Digest, Sha1}; | ||
| 6 | |||
| 7 | use crate::errors::McError; | ||
| 8 | |||
| 9 | pub async fn sha1_hex(path: &Path) -> Result<String, McError> { | ||
| 10 | let data = tokio::fs::read(path).await?; | ||
| 11 | let mut hasher = Sha1::new(); | ||
| 12 | hasher.update(&data); | ||
| 13 | Ok(format!("{:x}", hasher.finalize())) | ||
| 14 | } | ||
