summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/hash.rs38
1 files changed, 0 insertions, 38 deletions
diff --git a/src/core/hash.rs b/src/core/hash.rs
deleted file mode 100644
index 36a62b3..0000000
--- a/src/core/hash.rs
+++ /dev/null
@@ -1,38 +0,0 @@
-use blake3::Hasher as Blake3Hasher;
-use sha2::{Digest as Sha2Digest, Sha256};
-
-const SALT: &[u8] = b"Dude@";
-
-#[derive(Debug, Default)]
-pub enum ChunkWriteHash {
- #[default]
- Blake3,
- Sha256,
-}
-
-impl ChunkWriteHash {
- pub fn hash(&self, d: &[u8]) -> [u8; 32] {
- match self {
- ChunkWriteHash::Blake3 => hash_blake3(d),
- ChunkWriteHash::Sha256 => hash_sha256(d),
- }
- }
-}
-
-/// Compute the Blake3 hash of the data with a salt
-/// Returns a 32-byte hash value
-pub fn hash_blake3(d: &[u8]) -> [u8; 32] {
- let mut hasher = Blake3Hasher::new();
- hasher.update(SALT);
- hasher.update(d);
- *hasher.finalize().as_bytes()
-}
-
-/// Compute the SHA-256 hash of the data with a salt
-/// Returns a 32-byte hash value
-pub fn hash_sha256(d: &[u8]) -> [u8; 32] {
- let mut hasher = Sha256::new();
- hasher.update(SALT);
- hasher.update(d);
- hasher.finalize().into()
-}