Sunday, November 2, 2014

Beginning Cryptography - Decrypting XOR Encryption

In the first post in this series we looked at definitions. In the previous post we looked at the Caesar Cipher. In this post we will look at the Decrypting XOR Encryption


 "Exclusive-OR (XOR) encryption is an encryption method that is hard to break through with so called “brute force” methods (brute force = using random encryption keys in the hope you find the correct one.), but the encryption method is susceptible to pattern recognition. Patterns can be easily avoided by first compressing the file (compression already makes it unreadable, it removes patterns for you) before it is encrypted."


"The XOR encryption method doesn’t make use of a public-key, such as RSA. Instead both the people that encrypt the file as well as the people that want to decrypt the file need to have the encryption key. The exclusive-OR encryption (as the name already tells you) makes use of the Boolean algebra function XOR."

"The XOR function is a binary operator, which means that it takes two arguments when you use it.
If one of the two arguments is true and the other argument is false, then the XOR function will return true."



In our example XOR Encryption: XOR encryption has been used to encrypt a word made up of seven characters. The cipher text of the word is as follows:

00010000

00011011

00010110

00000111

00001100

00000101

00000001

The key is: 01010101

Answer:
Cipher Text + XOR Key:  
0001 0000       0001 1011       0001 0110       0000 0111       0000 1100       0000 0101
0101 0101       0101 0101       0101 0101       0101 0101       0101 0101       0101 0101
0100 0101       0100 1110       0100 0011       0101 0010       0101 1001       0101 0000

0000 0001
0101 0101
0101 0100

Binary Value after XORing
After XORing the Binary Value is:
0100 0101       0100 1110       0100 0011       0101 0010       0101 1001        0101 0000  0101 0100

Binary =  Hex Value = Ascii Character
0100 0101 = 45 = E   
0100 1110 = 4E = N
0100 0011 = 43 = C   
0101 0010 = 52 = R   
0101 1001 = 59 = Y   
0101 0000 = 50 = P
0101 0100 = 54 = T

The decrypted text is “ENCRYPT”

Reference:
http://www.codingunit.com/exclusive-or-xor-encryption

No comments:

Post a Comment