What is XOR encryption?

XOR encryption is a trivially simple symmetric cipher which is used in many applications where security is not a defined requirement.

The XOR Operator

XOR, also know as Exclusive OR, is a bitwise operator from binary mathematics.

The six bitwise operators, as defined in the C programming language, are:

OperationSymbol
AND&
Inclusive OR|
Exclusive OR (XOR)^
Right Shift>>
Left Shift<<
Complement~

The XOR operator returns a 1 when the value of either the first bit or the second bit is a 1.

The XOR operator returns a 0 when neither or both of the bits is 1.

This is best illustrated in the following chart:

First BitSecond BitResult
000
011
101
110

The XOR operator is used to "flip" bits (zeroes and ones) in a piece of plaintext to create a ciphertext.

Converting Plaintext to Ciphertext with XOR Encryption

The plaintext we will start with is the term "FAQ".

We will XOR the first character of this plaintext into ciphertext using a "V" as the key:

Plaintext 'F'Key 'V'Ciphertext
011
101
101
101
000
011
000
011

Converting Ciphertext to Plaintext with XOR Encryption

XOR encryption is a symmetric algorithm. This means that we can use the encryption key as the decryption key.

Let's decrypt our ciphertext to recreate our original plaintext.

CiphertextKey 'V'Plaintext
110
101
101
101
000
110
000
110

Do the math yourself with the other two characters of plaintext to prove this to yourself.

Many encryption algorithms utilize the XOR operator as part of their operations.

Understanding XOR and the other binary operators is a necessary step on the path to becoming a cryptologist.

XOR Security

XOR encryption is trivially simple to implement and equally trivial to break.

XOR encryption should not be utilized for any data which you would want to protect.

Applied Cryptography Handbook of Applied Cryptography Cryptography RSA Security's Official Guide to Cryptography
Purchase these excellent books on cryptology at Amazon.com


Top 5 Free Networking Tools

Bookmark What is XOR encryption?

Latest Blog Posts


English English GermanGerman SpanishSpanish FrenchFrench ItalianItalian PortuguesePortuguese RussianRussian DutchDutch
GreekGreek HindiHindi JapaneseJapanese KoreanKorean ChineseChinese Chinese (Simplified)Chinese (Simplified) ArabicArabic

Copyright 2009 Tech-FAQ. All rights reserved. Privacy Policy.