Home     Blog

XOR Encryption

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

The XOR Operator

XOR (Exclusive OR) is a bitwise operator from binary mathematics.

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

Operation Symbol
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. XOR Encryption

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

This is best illustrated in the following chart:

First Bit Second Bit Result
0 0 0
0 1 1
1 0 1
1 1 0

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 being started with is the term “FAQ.”

  • ASCII representation of the plaintext: FAQ
  • Hexadecimal representation of the plaintext: 70 65 81
  • Binary representation of the plaintext: 01110000 01100101 1000000

XOR the first character of this plaintext into ciphertext using a “V” as the key:

  • ASCII representation of the key: V
  • Hexadecimal representation of the key: 86
  • Binary representation of the key: 10000110
Plaintext ‘F’ Key ‘V’ Ciphertext
0 1 1
1 0 1
1 0 1
1 0 1
0 0 0
0 1 1
0 0 0
0 1 1

Converting Ciphertext to Plaintext with XOR Encryption

XOR encryption is a symmetric algorithm. This means that the encryption key can be used as the decryption key.

Decrypt the ciphertext to recreate the original plaintext.

Ciphertext Key ‘V’ Plaintext
1 1 0
1 0 1
1 0 1
1 0 1
0 0 0
1 1 0
0 0 0
1 1 0

Users should do the math themselves with the other two characters of plaintext to prove this to themselves.

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 simple to implement and equally simple to break.

XOR encryption should not be utilized for any data that the user wants to protect.

VN:F [1.9.17_1161]
Rating: 10.0/10 (1 vote cast)
XOR Encryption, 10.0 out of 10 based on 1 rating
Follow Will.Spencer on

Comments (1)

 

  1. Dezmats says:

    So how you brake it ? exemple. Yahoo .dat files are encrypted with XOR. right?

    VA:F [1.9.17_1161]
    Rating: 0.0/5 (0 votes cast)

Leave a Reply

Related Posts

  • Plaintext and Ciphertext

    Plaintext Plaintext, also known as cleartext, is usable data. It is data either before encryption or after successful decryption. Ciphertext Ciphertext is encrypted data. Plaintext can not be deduced from properly encrypted ciphertext. Here is a brief message in ciphertext: pgAAADP1wJU8OtQgiOPV9b+EyS6Iz6acuGAKrm1 GEcI4eJJolT68cOb1H/o/PxZ8 nYIs0UupT+0= =7mu0 Encryption and Decryption Encryption is the process of turning plaintext into [...]...


  • Known Ciphertext Attack

    A known ciphertext attack is an an attack where the cryptanalyst only has access to encrypted ciphertext. A known ciphertext attack is the easiest of the common cryptanalysis attacks to mount, because is requires the least amount of control over the encryption device. Conversely, the known ciphertext is the most difficult of the common methods [...]...


  • Known Plaintext Attack

    A known plaintext attack is an attack where the cryptanalyst has access to the ciphertext and the plaintext of one or more pieces of data. A known plaintext attack is somewhat easier to mount than a chosen plaintext attack, because a known plaintext attack does not require the cryptanalyst to be able to feed data [...]...


  • ROT-13

    ROT-13 is a simple substitution cipher used to obfuscate Usenet posts. ROT-13 is not meant for use as a data encryption cipher. ROT-13 is so named because every character is rotated 13 places. ROT-13 “Encryption” Chart Plaintext A B C D E F G H I J K L M N O P Q R [...]...


  • Chosen Plaintext Attack

    A chosen plaintext attack is an attack where the cryptanalyst is able to define his own plaintext, feed it into the cipher, and analyze the resulting ciphertext. Mounting a chosen plaintext attack requires the cryptanalyst to be able to send data of his choice into the device which is doing the encryption, and it requires [...]...