Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- This is an example of how the bitwise XOR can be used to make a simple encryption system.
- Suppose Alice wants to send the message `CAT` to Bob using the key `11000101`.
- __First:__ Convert the characters in the message to ASCII:
- + `C = 01000011`
- + `A = 01000001`
- + `T = 01010100`
- __Second:__ Alice shares the key with Bob.
- __Third:__ Perform bitwise XOR of each bitstring in the message with the key. (Using `xor` for this since math notation not supported here.)
- + `01000011 xor 11000101 = 10000110`
- + `01000001 xor 11000101 = 10000100`
- + `01010100 xor 11000101 = 10010001`
- __Fourth:__ Alice sends the encrypted message `01000011 01000001 01010100` to Bob. If an eavesdropper intercepted the message and tried convert this sequence back to ASCII characters, they'd get three indecipherable control characters. (Check the table.)
- __Fifth:__ Bob receives the message and XOR's each bitstring with the key:
- + `10000110 xor 11000101 = 01000011`
- + `10000100 xor 11000101 = 01000001`
- + `10010001 xor 11000101 = 01010100`
- __Sixth:__ Bob does a reverse lookup in the ASCII table (or using a computer) to convert from binary back to characters:
- + `01000011 = C`
- + `01000001 = A`
- + `01010100 = T`
- And that's the original message.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement