Advertisement
Guest User

Untitled

a guest
Oct 13th, 2015
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. This is an example of how the bitwise XOR can be used to make a simple encryption system.
  2.  
  3. Suppose Alice wants to send the message `CAT` to Bob using the key `11000101`.
  4.  
  5. __First:__ Convert the characters in the message to ASCII:
  6.  
  7. + `C = 01000011`
  8. + `A = 01000001`
  9. + `T = 01010100`
  10.  
  11. __Second:__ Alice shares the key with Bob.
  12.  
  13. __Third:__ Perform bitwise XOR of each bitstring in the message with the key. (Using `xor` for this since math notation not supported here.)
  14.  
  15. + `01000011 xor 11000101 = 10000110`
  16. + `01000001 xor 11000101 = 10000100`
  17. + `01010100 xor 11000101 = 10010001`
  18.  
  19. __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.)
  20.  
  21. __Fifth:__ Bob receives the message and XOR's each bitstring with the key:
  22.  
  23. + `10000110 xor 11000101 = 01000011`
  24. + `10000100 xor 11000101 = 01000001`
  25. + `10010001 xor 11000101 = 01010100`
  26.  
  27. __Sixth:__ Bob does a reverse lookup in the ASCII table (or using a computer) to convert from binary back to characters:
  28.  
  29. + `01000011 = C`
  30. + `01000001 = A`
  31. + `01010100 = T`
  32.  
  33. And that's the original message.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement