also initial commit
This commit is contained in:
Kaushik Narayan R 2024-01-31 15:41:22 -07:00
commit 640aa3e9af
7 changed files with 30 additions and 0 deletions

10
hw1.1/1a.py Normal file
View File

@ -0,0 +1,10 @@
with open("3/forstudents/a/ciphertext.bin", "rb") as cipher_file, open(
"3/forstudents/a/key.bin", "rb"
) as key_file:
cipher_content = cipher_file.read()
key_content = key_file.read()
print(
((
int.from_bytes(cipher_content, "big") ^ int.from_bytes(key_content, "big")
).to_bytes(max(len(cipher_content), len(key_content)), "big")).decode()
)

19
hw1.1/1b.py Normal file
View File

@ -0,0 +1,19 @@
with open("3/forstudents/b/ciphertext1.bin", "rb") as cipher1_file, open(
"3/forstudents/b/ciphertext2.bin", "rb"
) as cipher2_file, open("3/forstudents/b/plaintext1.txt", "r") as plain_unknown_file:
cipher1_content = cipher1_file.read()
cipher2_content = cipher2_file.read()
plain_unknown_content = plain_unknown_file.read()
possible_key = (
int.from_bytes(cipher1_content, "big")
^ int.from_bytes(bytes(plain_unknown_content, "utf-8"), "big")
).to_bytes(max(len(cipher1_content), len(plain_unknown_content)), "big")
print(
(
(
int.from_bytes(cipher2_content, "big")
^ int.from_bytes(possible_key, "big")
).to_bytes(max(len(cipher2_content), len(possible_key)), "big")
).decode("latin-1")
)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1 @@
-out-the-important-messages-ever-more-surely--Bratton-and-Kramer-hustled-from-place-to-place-with-their-locked-briefcases--MAGIC-gushed-forth-in-profusion--So-effectively-did-the-cryptanalytic-agencies-perform-that-Marshall-could-say-of-this--priceless-asset---this-most-complete-and-up-to-the-minute-intelligence-that-any-nation-had-ever-had-concerning-a-probable-enemy--this-necromantic-gift-of-the