summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-03-07 19:37:52 +0800
committer魏曹先生 <1992414357@qq.com>2026-03-07 19:37:52 +0800
commit9e7c0fd45e169929156bdb317b10d7bb3db65f8b (patch)
tree94c1e0e6cafe996b7b7da8dfd6e1ff1a04539cda /src/core
parent22926ce29e3f8e040ec349401aeb6a77f32eae72 (diff)
Add callback support to chunk_stream_with and implement stream writing
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()
-}