summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-04-23 11:18:20 +0300
committerLars Wirzenius <liw@liw.fi>2021-04-23 11:18:20 +0300
commit28c1652e0fa61563def69343141ac6c06854eaa6 (patch)
tree31836b7a5d22f50b5e7d8699fe75ee44ce156c56
parent35f3c2a309b7a39a079dc8223d3cc8da3f6704f7 (diff)
downloadsummain-rs-28c1652e0fa61563def69343141ac6c06854eaa6.tar.gz
move hashing to func
-rw-r--r--src/lib.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/lib.rs b/src/lib.rs
index cc1a751..becc8f3 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -97,12 +97,16 @@ fn file_checksum(path: PathBuf) -> std::io::Result<String> {
if n == 0 {
break;
}
- hasher.update(&buf[..n]);
+ update_checksum(&mut hasher, &buf[..n]);
}
let hash = hasher.finalize();
Ok(format!("{:x}", hash))
}
+fn update_checksum(hasher: &mut Sha256, data: &[u8]) {
+ hasher.update(data);
+}
+
mod mode {
use serde::{self, Serializer};