Skip to content

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.

License

yojiwatanabe/break_xor_key

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

break_xor_key.py

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.

Running the program:

  1. 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:
    07 0d 17 4f 55 07 0d 1c 0a 01 1c 0d 0d 1d 44 1b 48 1d 1f 58
    
    note: encrypted messages should be stored in hexadecimal separated by a space (' ')
  2. 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
    

Disclaimer:

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.

About

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.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages