Exclusive-OR
(or XOR
function is worth examining as a simple
example of a symmetric encryption method.
XOR
is a bitwise (or Boolean)
operator, with the following truth table:
Most programming languages provide an
A
B
A XOR B
0
0
0
0
1
1
1
0
1
1
1
0
XOR
function. To "encrypt" (for example) a byte of data, we could do
(in Java, all variables of Java primitive type
"byte
"):
The symmetric aspect ofcipher = plainText ^ key;
XOR
comes from the fact that to recover the plain text, we can simply
repeat the operation on the ciphertext:
Symmetic encryption and decyption (ie, using the same algorithm and key to both encrypt and decrypt) is a characteristic of all "single-key" encryption systems, unlike "Public Key" systems, see next lecture. TheplainText = cipher ^ key;
XOR
function is used one component among many
in "Real World" encryption algorithms.