intro lesson 8: the key is way shorter than the message, Shannon would not be happy.
This commit is contained in:
parent
e73c803ae3
commit
591979d7ef
2 changed files with 12 additions and 2 deletions
12
intro.py
12
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")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue