In this activity, you will learn to use the XOR cipher as a key to decrypt ciphertext to its original bitstream. Here is the process.
Let’s say I wanted to transmit the character “J” securely. The ASCII representation of the J is 01001010. In this case, 01001010 would be considered the plaintext, one of the inputs to an encryption algorithm.
But I don’t want to transmit this original bitstream. I want to encrypt it, and transmit the ciphertext instead. The key that I’ve randomly generated is 01100010.
I now feed both the plaintext and the key into the encryption algorithm. The algorithm I’ve chosen is the XOR cipher, which by itself doesn’t represent a strong algorithm. However, the XOR cipher is commonly used as a part of larger cryptographic algorithms.
Remember your Boolean logic and truth tables?
If there are two inputs, and either the first or the second bit is a 1, a 1 is produced on the output:
Cryptography commonly uses a derivation of the Logical OR, the Logical Exclusive OR (XOR).
Using XOR, a 1 is produced on the output if the first or the second bit is a 1, but not both. From this, we can see a pattern:
When the two input bits are the same (0,0 or 1,1) the result is a 0.When the two input bits are different (0,1 or 1,0), the result is a 1.When I apply the algorithm to the plaintext and key, the result produced is called ciphertext, the jumbled output that a man-in-the-middle would see, but not be able to understand.
Converting the J to ciphertext looks like this:
I send my receiver both the ciphertext and key, and she applies the same algorithm:
The result produced is the original bitstream, the plaintext.
Now it’s your turn!
Someone just sent me these 3 bytes: 10101001 01000110 11100001
He told me that the bytes are ASCII characters, encrypted with the XOR cipher, using this key:11111011 00001111 10110101
Can you use the XOR algorithm to decode the plaintext in both binary and ASCII characters?
Enter your answers in the problem below.
转载于:https://www.cnblogs.com/sec875/articles/10321352.html
相关资源:JAVA上百实例源码以及开源项目