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
|
|
@ -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
|
||||
|
|
|
|||
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