diff options
| author | gingerBill <bill@gingerbill.org> | 2021-12-29 12:01:07 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2021-12-29 12:01:07 +0000 |
| commit | a9b17b5a37b611dae51da6153de8239dfa08f202 (patch) | |
| tree | 8bc0db725f5c714bba390ca884511d9376112c03 /core/hash | |
| parent | a66f859fb49b2d31809767aaa8b4d8872b73c062 (diff) | |
Add `hash.djbx33a`
Diffstat (limited to 'core/hash')
| -rw-r--r-- | core/hash/djbx33a.odin | 18 |
1 files changed, 18 insertions, 0 deletions
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 |