summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs
index b37873b..32102f2 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,7 +1,9 @@
+use sha2::{Digest, Sha256};
+
fn main() {
let blobs = Blobs::new(128 * 1024);
for blob in blobs.take(10) {
- println!("{}", blob.len());
+ println!("{}", sha256(&blob));
}
}
@@ -22,3 +24,10 @@ impl Iterator for Blobs {
Some(vec![0; self.size])
}
}
+
+fn sha256(data: &[u8]) -> String {
+ let mut hasher = Sha256::new();
+ hasher.update(data);
+ let hash = hasher.finalize();
+ format!("{:x}", hash)
+}