If you understand how XOR works, you will be able to do it yourself quite simply.
First you have a set of data, say an array of chars representing the string "lol". ['l','o','l']
Then you have a key which is a number, possibly 17. Since Exclusive Or (XOR, ^) is a bitwise operator, you must look at the data in a binary sense. Exclusive or looks at 2 bits. If ONE of them is true, it is true, and if neither OR both are true, it is false. Here is a truth table to demonstrate:
Now you need to convert each character in the array of strings to binary. To do so, you probably want to use an ASCII table to get the decimal, and then proceed to do a simple base-10 to base-2 conversion.
"l" in binary is - 01101100
"o" in binary is - 01101111
17 in binary is - 00010001
Now we want to use XOR between each bit of the character and each bit of the key for each character in the array.
XOR together = 01111101
So the crypted 'l' is now that binary value and its character equivalent.
If you were to XOR that new value against the key again, it would return the original 'l'.
Hope this helps a bit
Oh no! Vortex is gay!
The Following 2 Users Say Thank You to Saltine For This Useful Post: