-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathS03C19C20.py
More file actions
36 lines (27 loc) · 754 Bytes
/
S03C19C20.py
File metadata and controls
36 lines (27 loc) · 754 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Imports
import os
import base64
from lib import *
def main():
# Given
b64_strings = open("20.txt").readlines()
nonce = 0
random_key = os.urandom(16)
decoded_strings = [base64.b64decode(line.strip()) for line in b64_strings]
ciphertext_list = [CTR(string, random_key, nonce) for string in decoded_strings]
min_ciphertext_length = min(map(len, ciphertext_list))
columns = []
for i in range(min_ciphertext_length):
line = b""
for cipher in ciphertext_list:
line += cipher[i].to_bytes(1, "big")
result = single_byte_xor_score(line)
columns.append(result["message"])
message = ""
for i in range(min_ciphertext_length):
for c in columns:
message += c[i]
print(message)
return
if __name__=="__main__":
main()