This program demonstrates the single key exploit by way of ciphertext decryption. The single key exploit has also been know to go by other names including one-time pad and many-time pad.
Single Key Exploit is a python program that decrypts ciphertext. This ciphertext has been encrypted using a single key for each message, leading to the single key exploit. Upon execution, the program will display the plaintext message that will be encrypted. Then it will try to decrypt as much of the encrypted text as possible. The resulting decrypted text will be output to the user.
To execute run the command python3 main.py
display_info()-
Description:
Outputs plain text to be encrypted
-
Parameters:
None
-
Return:
msgsList containing strings to be encryptedkeyList of bytes representing the encryption key
make_cipher(text, key)-
Description:
Creates a list of strings representing ciphertext
-
Parameters:
textList representing plaintextkeyList of bytes representing the encryption key -
Return:
cipherList containing ciphertext
encrypt(msg, key)-
Description:
Encrypts plain text using an encryption key
-
Parameters:
magString to be encryptedkeyList representing encryption key -
Return:
bytesString representing encrypted text in hexadecimal
preprocess(text)-
Description:
Turns encrypted text into hexadecimal and initializes a list of dashes acting as placeholders
-
Parameters:
textList containing ciphertext -
Return:
hexList representing hexadecimal representation of encrypted textplace_holdersList containing dashes -
break_encryption(encrypted_text, decrypted_text)-
Description:
Attempts to break encryption by utilizing XOR operations
-
Parameters:
encrypted_textList containing the ciphertextdecrypted_textList of placeholders to store decrypted text -
Return:
cracked_cipherList of decrypted text
ascii_space(not_cracked, current_char, columns)-
Description:
Checks a character to determine if it is a space
-
Parameters:
not_crackedList containing text that has not been decryptedcurrent_charChar representing the current character that is being test to determine if it is a spacecolumnsInt representing the index of the current character we are testing -
Return:
BoolTrue if a space is found, False otherwise
output_text(text)-
Description:
Outputs the decrypted text
-
Parameters:
textList containing decrypted text -
Return:
None
To learn more about this encryption vulnerability refer to this article: One-time Pad