enabled bruteforce and added source notice

This commit is contained in:
Christoph J. Scherr 2023-04-22 12:19:12 +02:00
parent 314b12c287
commit 46d7dd331a
Signed by: PlexSheep
GPG Key ID: 25B4ACF7D88186CC
1 changed files with 4 additions and 6 deletions

View File

@ -6,6 +6,7 @@ you also need the chiffrat.txt file in the same directory.
License: MIT
author: Christoph J. Scherr <software@cscherr.de>
source: https://git.cscherr.de/PlexSheep/python-dhbw/src/branch/master/src/basic-decrypt.py
"""
MAX_IN_LINE = 16
@ -69,12 +70,9 @@ def find_key(freq: dict, language_reference: list, full_text: list):
print("Caesar keys ambiguos: %s" % caesar_keys)
# was not caesar encrypted, continue with XOR checks
# XOR
#for xor_key in range(0, 2**7):
# decrypt = bytes(xor_key ^ common_char for common_char in full_text)
# try:
# print(("decry for kex %x:\t%s" % (xor_key, decrypt.decode(errors="backslashreplace"))).replace("\n", ""))
# except:
# print(("decry for kex %x:\t%s" % (xor_key, decrypt.hex())).replace("\n", ""))
for xor_key in range(0, 2**6):
decrypt = bytes(xor_key ^ common_char for common_char in full_text)
print(("decry for kex %x:\t%s" % (xor_key, decrypt.decode(errors="backslashreplace"))).replace("\n", ""))
# -> manual review of the output of the above confirmed that the key for my cyphertext is 0x15
THE_KEY = 0x15