Xor Keyword
The xor
operator performs
an exclusive or
on its operands. If the operands
are of Boolean type, it returns a Boolean result: True if the
operands are different and False if they are the same.
An integer xor
operates on each bit of its
operands, setting the result bit to 1 if the corresponding bits in
both operands are different, and to
if both operands have identical bits. If one operand is smaller than
the other, Delphi extends the smaller operand with
in the leftmost bits. The result is the size of the largest operand.
With Boolean operands, xor
is just like comparing
for inequality. In most cases, the <>
operator is easier to understand than using xor
.
The xor
operation is reversible, which leads some
people to use it for encrypting passwords. Using
xor
to encrypt passwords is like using bubble gum
to lock a door. It doesn’t work, and it’s easy to break
in. Search the World Wide Web to find free, reusable solutions for
securely encrypting passwords.