Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is XOR Encryption?

Tags:

encryption

xor

I have heard about people starting encryption and thought it may be something I would like, so I checked XOR and can't make any sense of it. So can someone explain to me what XOR is ?

like image 1000
H4cKL0rD Avatar asked Jan 08 '10 17:01

H4cKL0rD


2 Answers

you take a key, such as 0101, then you use that to XOR your string (in binary format) to achieve an encrypted string.

0101 XOR <-- key
1011 <---- original message
----
1110 <-- send message

You send 1110 to your receiver. That receiver, then takes the received string and XORs it with the key to obtain the original message:

1110 XOR <--- received message
0101 <-- key
----
1011 <--- original message
like image 126
z - Avatar answered Oct 13 '22 07:10

z -


XOR, or 'exclusive or' is a 2 operand logical operation defined as:

(a and b) or (not a and not b)

 a  b  result
 0  0  0
 1  0  1
 0  1  1
 1  1  0

The critical feature of XOR with respect to encryption is it is reversible, ie where C = A XOR B, then you can get back A using A = C XOR B.

So for a stream of plaintext A, and a key of the same length B, you can generate cryptotext C, and send that to the recipient.

The recipient, who has a copy of B in his safe, can do C XOR B and regenerate A.

like image 33
Alex Brown Avatar answered Oct 13 '22 05:10

Alex Brown