summaryrefslogtreecommitdiff
path: root/shared
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2025-01-12 22:18:08 +0100
committermetamuffin <metamuffin@disroot.org>2025-01-12 22:18:08 +0100
commit32b749262d305b5ce09d1fc0c02f40023033c9bd (patch)
tree9088d5309febd3102e758b3f82d0eede4b26bac5 /shared
parent2731017aa88bf6baaff787d7486d4248f9ca6ca0 (diff)
downloadweareserver-32b749262d305b5ce09d1fc0c02f40023033c9bd.tar
weareserver-32b749262d305b5ce09d1fc0c02f40023033c9bd.tar.bz2
weareserver-32b749262d305b5ce09d1fc0c02f40023033c9bd.tar.zst
sha256 -> blake3
Diffstat (limited to 'shared')
-rw-r--r--shared/Cargo.toml2
-rw-r--r--shared/src/store.rs7
2 files changed, 4 insertions, 5 deletions
diff --git a/shared/Cargo.toml b/shared/Cargo.toml
index 8665019..394983a 100644
--- a/shared/Cargo.toml
+++ b/shared/Cargo.toml
@@ -8,6 +8,6 @@ anyhow = "1.0.95"
bincode = "1.3.3"
glam = { version = "0.29.2", features = ["serde"] }
redb = "2.4.0"
-sha2 = "0.11.0-pre.4"
log = "0.4.22"
rand = "0.9.0-beta.1"
+blake3 = "1.5.5"
diff --git a/shared/src/store.rs b/shared/src/store.rs
index 37e3ab1..673a40e 100644
--- a/shared/src/store.rs
+++ b/shared/src/store.rs
@@ -17,7 +17,6 @@
use crate::{helper::ReadWrite, packets::Resource};
use anyhow::Result;
use redb::{Database, TableDefinition};
-use sha2::{Digest, Sha256};
use std::{collections::HashMap, marker::PhantomData, path::Path, sync::Mutex};
const T_ENTRIES: TableDefinition<[u8; 32], &[u8]> = TableDefinition::new("e");
@@ -59,7 +58,7 @@ impl ResourceStore {
}
}
pub fn set_raw(&self, value: &[u8]) -> Result<Resource> {
- let key = Resource(sha256(value), PhantomData);
+ let key = Resource(resource_hash(value), PhantomData);
match self {
ResourceStore::Redb(database) => {
let txn = database.begin_write()?;
@@ -85,8 +84,8 @@ impl ResourceStore {
}
}
-pub fn sha256(x: &[u8]) -> [u8; 32] {
- let mut hasher = Sha256::new();
+pub fn resource_hash(x: &[u8]) -> [u8; 32] {
+ let mut hasher = blake3::Hasher::new();
hasher.update(x);
hasher.finalize().into()
}