std.hash
non-crypto hashes (FNV-1a, CRC-32, Adler-32, XXH64), one-shot or streaming not attack-resistant; use std.crypto for adversarial input
Hasher
Section titled “Hasher”pub Hasher :: interface { update :: fn(self: *Self, data: []const u8);}incremental hasher; all of these plus std.crypto’s Sha256
pub feed :: fn(h: *Hasher, src: *Reader, buf: []u8) -> u64 ! IoErrorhashes all of src through buf; returns bytes hashed
fnv1a_64
Section titled “fnv1a_64”pub fnv1a_64 :: fn(data: []const u8) -> u64quick for short keys
fnv1a_32
Section titled “fnv1a_32”pub fnv1a_32 :: fn(data: []const u8) -> u32Fnv1a64
Section titled “Fnv1a64”pub Fnv1a64 :: struct { state: u64,}streaming; from fnv1a_64_start
Fnv1a64.update
Section titled “Fnv1a64.update”pub update :: fn(self: *Self, data: []const u8)Fnv1a64.final
Section titled “Fnv1a64.final”pub final :: fn(self: *Self) -> u64fnv1a_64_start
Section titled “fnv1a_64_start”pub fnv1a_64_start :: fn() -> Fnv1a64Fnv1a32
Section titled “Fnv1a32”pub Fnv1a32 :: struct { state: u32,}streaming; from fnv1a_32_start
Fnv1a32.update
Section titled “Fnv1a32.update”pub update :: fn(self: *Self, data: []const u8)Fnv1a32.final
Section titled “Fnv1a32.final”pub final :: fn(self: *Self) -> u32fnv1a_32_start
Section titled “fnv1a_32_start”pub fnv1a_32_start :: fn() -> Fnv1a32pub crc32 :: fn(data: []const u8) -> u32crc32(“123456789”) == 0xCBF43926
pub Crc32 :: struct { crc: u32,}streaming; from crc32_start
Crc32.update
Section titled “Crc32.update”pub update :: fn(self: *Self, data: []const u8)Crc32.final
Section titled “Crc32.final”pub final :: fn(self: *Self) -> u32crc32_start
Section titled “crc32_start”pub crc32_start :: fn() -> Crc32xxhash64
Section titled “xxhash64”pub xxhash64 :: fn(seed: u64, data: []const u8) -> u64seed 0 is the usual; xxhash64(0, “”) == 0xEF46DB3751D8E999
XxHash64
Section titled “XxHash64”pub XxHash64 :: struct { seed: u64, v1: u64, v2: u64, v3: u64, v4: u64, buf: [32]u8, buffered: usize, total: u64,}streaming; from xxhash64_start; a partial round waits in buf
XxHash64.update
Section titled “XxHash64.update”pub update :: fn(self: *Self, data: []const u8)XxHash64.final
Section titled “XxHash64.final”pub final :: fn(self: *Self) -> u64xxhash64_start
Section titled “xxhash64_start”pub xxhash64_start :: fn(seed: u64) -> XxHash64adler32
Section titled “adler32”pub adler32 :: fn(data: []const u8) -> u32as zlib appends it; adler32(“Wikipedia”) == 0x11E60398
Adler32
Section titled “Adler32”pub Adler32 :: struct { a: u32, b: u32,}streaming; from adler32_start
Adler32.update
Section titled “Adler32.update”pub update :: fn(self: *Self, data: []const u8)Adler32.final
Section titled “Adler32.final”pub final :: fn(self: *Self) -> u32adler32_start
Section titled “adler32_start”pub adler32_start :: fn() -> Adler32pub mix64 :: fn(x: u64) -> u64MurmurHash3 finalizer: full avalanche, for integer keys