Encryption
The XOR operation is a bitwise logical operation. Each bit in the destination operand becomes a 1 only if the corresponding bits in the two operands were different before the operation. For example, applying the XOR operation to the destination operand containing 'A' (ASCII 65) and the source operand the hex value A8:
Value/Expression | Binary |
6510 | 01100101 |
A816 | 10101000 |
6510 XOR A816 | 11001101 |
The XOR operation is useful for encrypting and decrypting a character because applying the operation twice regenerates the original character. Continuing with our example, we XOR the previous result with the hex value A8 again to regenerate denary 65, the ASCII code for 'A':
Value/Expression | Binary |
Encrypted 'A' | 11001101 |
A816 | 10101000 |
6510 | 01100101 |
Follow the links below for demonstration programs on encryption and decryption. See also our in-line assembler example of encryption by vector processing in Arrays for Enthusiasts.