From 591979d7efb1889c4e3e8f278b2d56180e8560d1 Mon Sep 17 00:00:00 2001 From: boyreau Date: Thu, 5 Nov 2026 11:52:31 +0100 Subject: [PATCH] intro lesson 8: the key is way shorter than the message, Shannon would not be happy. --- challenge.py | 2 ++ intro.py | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/challenge.py b/challenge.py index c4ac14d..dc9e298 100644 --- a/challenge.py +++ b/challenge.py @@ -6,6 +6,7 @@ from intro import ( xor_13, unxor_flag, mystery_xor, + mystery_key, ) if __name__ == "__main__": @@ -22,4 +23,5 @@ if __name__ == "__main__": 0x04ee9855208a2cd59091d04767ae47963170d1660df7f56f5faf )) print(mystery_xor(0x73626960647f6b206821204f21254f7d694f7624662065622127234f726927756d)) + print(mystery_key(0x0e0b213f26041e480b26217f27342e175d0e070a3c5b103e2526217f27342e175d0e077e263451150104)) # fmt: on diff --git a/intro.py b/intro.py index e12659a..e807cb3 100644 --- a/intro.py +++ b/intro.py @@ -17,8 +17,8 @@ def hex_to_ascii(input: str) -> str: # Challenge intro-3 -def hex_to_b64(input: str) -> bytes: - return base64.b64encode(bytes.fromhex(input)) +def hex_to_b64(input: str) -> str: + return base64.b64encode(bytes.fromhex(input)).decode("utf-8") # Challenge intro-4 @@ -49,3 +49,11 @@ def mystery_xor(input: int): candidate = xor(str_input, i).decode("utf-8") if candidate.startswith("crypto"): return candidate + + +# Challenge intro-6 +def mystery_key(input: int): + str_input = int_to_message_rsa(input) + key = xor(str_input, "crypto{1").decode("utf-8")[:8] + key = key + key + key + key + key + key + key + key + key + key + key + key + return xor(str_input, key[: len(str_input)]).decode("utf-8")