DJB2 Hash Generator
Generate the classic non-cryptographic times-33 text hash.
Apply the compact times-33 recurrence
DJB2 begins at 5381 and updates its 32-bit state by multiplying by 33, then adding each input byte. This page applies that recurrence to UTF-8 rather than JavaScript UTF-16 code units and wraps every step to an unsigned 32-bit value. The algorithm is tiny, fast, and still encountered in hash tables, examples, and legacy compatibility work.
The word hello produces 0f923099 in this byte-oriented implementation. Writing the update as hash shifted left five plus hash makes the factor of 33 visible, while Math.imul preserves low 32-bit multiplication. Non-ASCII text may disagree with a code-unit implementation, so the reported UTF-8 byte count helps identify an encoding mismatch.
Keep DJB2 inside benign lookup use cases
DJB2 offers no cryptographic protection and can be attacked with deliberate collision sets, especially in exposed hash tables. Its 32-bit space also guarantees collisions as input volume grows. Hashing occurs in your browser. Use it only when a target format explicitly calls for DJB2 or when benign distribution is sufficient; choose a keyed or cryptographic design for untrusted data.
Frequently Asked Questions
Why does DJB2 start at 5381?
That historical seed is part of the commonly reproduced algorithm, although its original selection is not a security parameter.
Does this hash Unicode code units?
No. It first encodes text as UTF-8 bytes for an explicit cross-platform byte sequence.
Is DJB2 safe for hostile hash-table keys?
No. Attackers can craft collisions; use a keyed, randomized hash designed for that threat.
Browse the full set of free, private, in-browser tools.