mirror of
https://github.com/20kaushik02/CSE548_ACNS_Work.git
synced 2025-12-06 07:44:07 +00:00
1.1 done
also initial commit
This commit is contained in:
commit
640aa3e9af
10
hw1.1/1a.py
Normal file
10
hw1.1/1a.py
Normal 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
19
hw1.1/1b.py
Normal 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")
|
||||
)
|
||||
BIN
hw1.1/3/forstudents/a/ciphertext.bin
Normal file
BIN
hw1.1/3/forstudents/a/ciphertext.bin
Normal file
Binary file not shown.
BIN
hw1.1/3/forstudents/a/key.bin
Normal file
BIN
hw1.1/3/forstudents/a/key.bin
Normal file
Binary file not shown.
BIN
hw1.1/3/forstudents/b/ciphertext1.bin
Normal file
BIN
hw1.1/3/forstudents/b/ciphertext1.bin
Normal file
Binary file not shown.
BIN
hw1.1/3/forstudents/b/ciphertext2.bin
Normal file
BIN
hw1.1/3/forstudents/b/ciphertext2.bin
Normal file
Binary file not shown.
1
hw1.1/3/forstudents/b/plaintext1.txt
Normal file
1
hw1.1/3/forstudents/b/plaintext1.txt
Normal 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
|
||||
Loading…
x
Reference in New Issue
Block a user