#non-cryptographic #checksum

no-std djb2

Tiny non-cryptographic checksum algorithm by D. J. Bernstein (1991, u32 XOR variant)

1 unstable release

Uses new Rust 2024

0.1.0 Dec 19, 2025

#149 in No standard library


Used in embedded-savegame

MIT-0 license

4KB

This algorithm (k=33) was first reported by dan bernstein many years ago (1991) in comp.lang.c. another version of this algorithm (now favored by bernstein) uses xor: hash(i) = hash(i - 1) * 33 ^ str[i]; the magic of number 33 (why it works better than many other constants, prime or not) has never been adequately explained.

https://www.cse.yorku.ca/~oz/hash.html

No runtime deps