Hamming Distance

Count differing positions between two equal-length inputs using the selected byte or bit comparison.

Input: TextResult: Text

Text input

Tool options

Examples

Count three substitutions in the classic string example

Byte distance counts changed positions, not insertions or deletions.

Input

karolin

kathrin

Expected answer

3
Delimiter
Unit
Byte
Input type
Raw string
Find a one-bit change in a two-byte packet

FF versus FE changes one bit in the second byte.

Input

00ff|00fe

Expected answer

1
Delimiter
|
Unit
Bit
Input type
Hex
Compare every bit in opposite byte values

Two opposite bytes differ in all 16 bit positions.

Input

0000|ffff

Expected answer

16
Delimiter
|
Unit
Bit
Input type
Hex
Count changed bytes in two IPv4-style headers

Only the final byte differs; this is a short synthetic header fragment.

Input

45000014|45000028

Expected answer

1
Delimiter
|
Unit
Byte
Input type
Hex
Separate byte changes from bit changes in ASCII

ASCII A and a differ by the single 0x20 bit.

Input

A|a

Expected answer

1
Delimiter
|
Unit
Bit
Input type
Raw string

Format reference: Hamming Distance background and specification

Parameters

ParameterDefault valueInput and choices
Delimiter"\\n\\n"Escape sequences such as \n, \r and \t are supported
UnitByteByte, Bit
Input typeRaw stringRaw string, Hex

Related tools

Browse utils tools