A simple Python script to find the key used in a XOR cipher. With a cleartext message and its XOR encrypted message, you can use this tool to find the key used to encode the messages. This can allow you to break future messages using the same XOR cipher key as well as encrypt your own messages with the same method.
- Ensure you have files containing the cleartext and encrypted message. Ensure files have only the parts of cipher, and no extra newlines, etc.
- example decrypted message file:
hey there secret spy
- example encrypted message file:
note: encrypted messages should be stored in hexadecimal separated by a space (' ')07 0d 17 4f 55 07 0d 1c 0a 01 1c 0d 0d 1d 44 1b 48 1d 1f 58
- Run
/usr/bin/python /Users/ywatanabe/Documents/code/break_xor_key/break_xor_key.py enc dec Text to decrypt: 07 0d 17 4f 55 07 0d 1c 0a 01 1c 0d 0d 1d 44 1b 48 1d 1f 58 Decrypted text: hey there secret spy ######################################## Decrypted key: ohno! ######################################## Process finished with exit code 0
This script is for educational purposes only. The author, Yoji Watanabe, is not responsible for the use of this script, repository, or any information contained inside it. Any action the user takes with this script (or any information) in it is solely the user's responsibility. Use at your own risk.