college-rowing-team

This commit is contained in:
Maxime Vorwerk
2024-07-31 17:08:17 +02:00
parent d7b7c52cfa
commit 7a1b134dd3
3 changed files with 129 additions and 0 deletions

29
college_rowing_team/encrypt.py Executable file
View File

@@ -0,0 +1,29 @@
#!python3
import random
from Crypto.Util.number import getPrime, bytes_to_long
with open('flag.txt', 'rb') as f:
flag = f.read()
msgs = [
b'I just cannot wait for rowing practice today!',
b'I hope we win that big rowing match next week!',
b'Rowing is such a fun sport!'
]
msgs.append(flag)
msgs *= 3
random.shuffle(msgs)
for msg in msgs:
p = getPrime(1024)
q = getPrime(1024)
n = p * q
e = 3
m = bytes_to_long(msg)
c = pow(m, e, n)
with open('encrypted-messages.txt', 'a') as f:
f.write(f'n: {n}\n')
f.write(f'e: {e}\n')
f.write(f'c: {c}\n\n')