add xmasspirit solve

This commit is contained in:
aaron
2021-12-04 01:44:49 +01:00
parent 935da1c9cd
commit 6a66280e54
4 changed files with 73 additions and 10 deletions

20
crypto/XMASSpirit/challenge.py Normal file → Executable file
View File

@@ -4,17 +4,17 @@ import random
from math import gcd
def encrypt(dt):
mod = 256
while True:
a = random.randint(1,mod)
if gcd(a, mod) == 1: break
b = random.randint(1,mod)
mod = 256
while True:
a = random.randint(1,mod)
if gcd(a, mod) == 1: break
b = random.randint(1,mod)
res = b''
for byte in dt:
enc = (a*byte + b) % mod
res += bytes([enc])
return res
res = b''
for byte in dt:
enc = (a*byte + b) % mod
res += bytes([enc])
return res
dt = open('letter.pdf', 'rb').read()