add xmasspirit solve
This commit is contained in:
20
crypto/XMASSpirit/challenge.py
Normal file → Executable file
20
crypto/XMASSpirit/challenge.py
Normal file → Executable 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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user