How to use the simple string hash tool
- Type or paste your string into Text. The default is
hello. - Read the table. Each row has the Algorithm, the Hex value (8 digits) and the Decimal value.
- Copy the row that matches the function your program uses.
What it does and when to use it
Programs use small hash functions to put keys into hash tables, split work across servers, build bloom filters and create cache keys. When a value in your code looks wrong, it helps to see the expected result from several well-known functions at once. This page also makes a good teaching aid, because you can watch how one changed letter affects each function differently.
For a single algorithm with variants and raw-byte input, use the DJB2 calculator or the FNV hash calculator. For secure digests of many algorithms together, see hash all.
How it works
All rows except Java hash the UTF-8 bytes of your text. The functions are written in the page’s own code, except xxHash32, CRC-32 and Adler-32, which come from the hash-wasm library. All run in your browser.
| Row | Idea in one line |
|---|---|
| djb2 / djb2a | start 5381; × 33, then add or XOR each byte |
| sdbm | byte + (h « 6) + (h « 16) − h |
| FNV-1 / FNV-1a | multiply by 16777619 and XOR, in either order |
| Jenkins one-at-a-time | add, shift and XOR per byte, final mix |
| MurmurHash3 x86 32 | 4 bytes at a time, rotate-multiply mixing, seed 0 |
| ELF / PJW | shift by 4, fold the top bits back in |
| Java String.hashCode() | h × 31 + UTF-16 code unit, signed |
| xxHash32 | 4-lane mixing, seed 0 |
| CRC-32, Adler-32 | standard checksums |
| Lose-lose | plain sum of the bytes |
Worked examples
hello. The tool shows Java String.hashCode() | 05e918d2 | 99162322, the same number Java prints for "hello".hashCode(). MurmurHash3 gives 248bfa47, djb2 gives 0f923099 and FNV-1a gives 4f9f2cab.
A famous Java collision. Aa and BB both give a Java hashCode of 2112 (00000840). In Aa, 65 × 31 + 97 = 2112; in BB, 66 × 31 + 66 = 2112. Their djb2 values differ (5862151 and 5862153), and the lose-lose sums are 162 and 132.
Empty text. The table shows each function’s starting state: djb2 5381, FNV 811c9dc5, Adler-32 1, xxHash32 02cc5d05, and 0 for most others.
Limits and tips
- Bytes or characters matter. For
é, Java hashes one UTF-16 unit (233), while the other rows hash two UTF-8 bytes. - Lose-lose is included as a bad example: every anagram, such as
listenandsilent, gets the same value. - Results are 32-bit. On 64-bit platforms some C versions of djb2 and sdbm keep more bits and differ for long strings.
- There is no hex or Base64 input on this page; it always hashes the text as typed.
Frequently asked questions
Is this a Caesar cipher?
Which hash should I pick for a hash table?
Why is the Java value negative sometimes?
Can any of these protect a password or prove a file is unchanged?
How do we know nothing is uploaded? Test it yourself on the privacy proof page.