Convert hasher to interface and remove spihash64
Release / release (push) Successful in 3s

This commit is contained in:
Abdelrahman Said
2026-09-16 01:08:06 +01:00
parent 8b3b1816b3
commit f73a870a34
12 changed files with 31 additions and 164 deletions
-40
View File
@@ -80,43 +80,3 @@ WpTestFuncResult test_siphash_128(void) {
return wpTesterResult(result);
}
WpTestFuncResult test_siphash_64(void) {
b8 result = true;
WpStr8 str = wpStr8Lit("Hello world");
WpI32Array arr = wpArray(i32, 1, 2, 3, 4, 5);
u64 num = 287324;
WpSipHasherKey key = { .lo = 238742, .hi = 671734 };
WpSipHasherData data = wpSip24HasherData(key);
WpU8Stream str_bytes = wpStream(u8, str.buf, str.size);
WpU8Stream arr_bytes = wpStream(u8, (u8 *)arr, wpArrayCount(arr) * wpArrayItemSize(arr));
WpU8Stream num_bytes = wpStream(u8, (u8 *)&num, sizeof(u64));
u64 hash = {0};
// Sring hash
u64 sip_hash = wpSipHasher64(&str_bytes, (void *)&data);
siphash(str_bytes.data, str_bytes.count * str_bytes.item_size, (void *)&data.key,
(u8 *)&hash, sizeof(u64));
result = result && sip_hash == hash;
// Array hash
sip_hash = wpSipHasher64(&arr_bytes, (void *)&data);
siphash(arr_bytes.data, arr_bytes.count * arr_bytes.item_size, (void *)&data.key,
(u8 *)&hash, sizeof(u64));
result = result && sip_hash == hash;
// Number hash
sip_hash = wpSipHasher64(&num_bytes, (void *)&data);
siphash(num_bytes.data, num_bytes.count * num_bytes.item_size, (void *)&data.key,
(u8 *)&hash, sizeof(u64));
result = result && sip_hash == hash;
return wpTesterResult(result);
}