The Hamming distance between two strings of equal length is the number of positions at which their symbols differ (Black 2006). For binary strings, this is the number of coordinates at which the corresponding vertices of a hypercube graph differ. For example, abc and bca have Hamming distance 3.
For binary strings and
of length
,
where
is the Hamming weight and
denotes bitwise XOR. Indeed, a
coordinate of
is 1 iff the corresponding coordinates of
and
differ. For any binary string
of length
, applying the same XOR mask to both
arguments gives
Thus common XOR masking is an isometry of the binary string space.