Hamming distance calculator

The number of positions where two strings, bit strings or hex values differ, with the differences marked.

How it works

The Hamming distance between two strings of the same length is the number of positions where they differ. Between karolin and kathrin it is 3. For bit strings it equals the number of ones in $a \oplus b$, the weight (popcount) of the XOR.

Richard Hamming introduced it in 1950 for error-correcting codes: if every two codewords are at distance at least $d$, then up to $d - 1$ flipped bits are detected and up to $\lfloor (d-1)/2 \rfloor$ corrected, by choosing the nearest codeword.

In cryptanalysis the bit-wise distance helps to find the key length of a repeating-key XOR (blocks encrypted with the same key byte are closer), and the avalanche effect of a good hash or cipher means that flipping one input bit changes about half the output bits.

Everything is calculated in your browser. Nothing you type leaves your device.