|
|
@ -5,7 +5,7 @@ from rich.prompt import Prompt
|
|
|
|
|
|
|
|
|
|
|
|
from cryptography_s_des_exploring.sdes.decrypt import decrypt_block
|
|
|
|
from cryptography_s_des_exploring.sdes.decrypt import decrypt_block
|
|
|
|
|
|
|
|
|
|
|
|
from cryptography_s_des_exploring.sdes.blocks import decode, decode_bytes
|
|
|
|
from cryptography_s_des_exploring.sdes.blocks import encode, decode, decode_bytes
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def cast_to_key(number: int):
|
|
|
|
def cast_to_key(number: int):
|
|
|
@ -18,15 +18,19 @@ def cracking(ciphertext):
|
|
|
|
|
|
|
|
|
|
|
|
start = time.monotonic()
|
|
|
|
start = time.monotonic()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
decoded_ciphertext = list(decode_bytes(ciphertext))
|
|
|
|
|
|
|
|
|
|
|
|
for n in range(0, 1024):
|
|
|
|
for n in range(0, 1024):
|
|
|
|
key = cast_to_key(n)
|
|
|
|
key = cast_to_key(n)
|
|
|
|
|
|
|
|
|
|
|
|
decoded = decode_bytes(ciphertext)
|
|
|
|
decrypted = list(map(lambda b: decrypt_block(key, b), decoded_ciphertext))
|
|
|
|
decrypted = list(map(lambda b: decrypt_block(key, b), decoded))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
decoded = decode(decrypted)
|
|
|
|
decoded_text = decode(decrypted)
|
|
|
|
founded.append((key, decoded))
|
|
|
|
|
|
|
|
|
|
|
|
if len(decrypted) == len(list(encode(decoded_text))):
|
|
|
|
|
|
|
|
founded.append((key, decoded_text))
|
|
|
|
|
|
|
|
|
|
|
|
except UnicodeDecodeError as e:
|
|
|
|
except UnicodeDecodeError as e:
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
except binascii.Error as e:
|
|
|
|
except binascii.Error as e:
|
|
|
|