XORing in Computer Science

I couldn’t find a nice concise method of how to encrypt and decrypt with XOR (Exclusive OR).

All the blogs give the background to Teredo Tunnelling but I already knew that and just wanted to know how to XOR.

So I share my simple method.

1. Convert Decimal/Hex to Binary
2. Layer with XOR ffff:ffff in Binary
3. Convert string with table below
4. Convert back into Hex

The description:

Take the IP:
In binary, this is: 10000011.01101011.00000000.00000001
In Hex it’s: 836b:0001
The XOR Hex is: ffff:ffff
Which in binary is: 1111.1111.1111.1111:1111.1111.1111.1111
Underneath I have layered the other binary number.  Using the table below, write the output :

1 xor 1 = 0
1 xor 0 = 1
0 xor 1 = 1
0 xor 0 = 0

Which is: 0111.1100.1001.0100:1111.1111.1111.1110



And convert the last string into Hex to get your XOR value: 7c94:fffe

And in reverse:
Take Hex: f5ff:ebfe
In binary this is: 1111.0101.1111.1111:1110.1011.1111.1110
Layer the XOR: 1111.1111.1111.1111:1111.1111.1111.1111

Use the table to convert the string so:
Convert this to Hex: 0a00:1401
Then into Binary: 00001010.00000000.00010100.00000001
Which gives you the IP:

Phew….time for a cup of tea!!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s