From a9b17b5a37b611dae51da6153de8239dfa08f202 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Wed, 29 Dec 2021 12:01:07 +0000 Subject: [PATCH] Add `hash.djbx33a` --- core/hash/djbx33a.odin | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 core/hash/djbx33a.odin diff --git a/core/hash/djbx33a.odin b/core/hash/djbx33a.odin new file mode 100644 index 000000000..db286b660 --- /dev/null +++ b/core/hash/djbx33a.odin @@ -0,0 +1,18 @@ +package hash + +djbx33a :: proc(data: []byte) -> (result: [16]byte) #no_bounds_check { + state := [4]u32{5381, 5381, 5381, 5381} + + s: u32 = 0 + for p in data { + state[s] = (state[s] << 5) + state[s] + u32(p) + s = (s + 1) & 3 + } + + + (^u32le)(&result[0])^ = u32le(state[0]) + (^u32le)(&result[4])^ = u32le(state[1]) + (^u32le)(&result[8])^ = u32le(state[2]) + (^u32le)(&result[12])^ = u32le(state[3]) + return +} \ No newline at end of file