using prohax

This commit is contained in:
neptunia 2017-03-17 20:25:52 -04:00
parent a7381752dc
commit b43da56e09

View file

@ -2,6 +2,7 @@ from cStringIO import StringIO
import os import os
from Crypto.Util import number from Crypto.Util import number
flag = "wow_"
def egcd(a, b): def egcd(a, b):
if a == 0: if a == 0:
@ -56,8 +57,6 @@ def randleetify(s, random):
i[c] = i[c].upper() i[c] = i[c].upper()
return ''.join(i) return ''.join(i)
flag = randleetify("i_probably_shouldnta_leeked_d",random)
def get_problem(random): def get_problem(random):
n_length = 2048 n_length = 2048
@ -70,7 +69,7 @@ def get_problem(random):
cut = len(bin(d).strip('0b').strip('L'))//2 - 2 cut = len(bin(d).strip('0b').strip('L'))//2 - 2
given = bin(d).strip('0b').strip('L')[cut:] given = bin(d).strip('0b').strip('L')[cut:]
deez = hex(int(given,2)).zfill(len(given)/4) deez = hex(int(given,2)).zfill(len(given)/4)
salt = random.choice("!?.") salt = randleetify("i_probably_shouldnta_leeked_d",random)
return (n, e, cut, deez, salt) return (n, e, cut, deez, salt)
def generate_ciphertext(random): def generate_ciphertext(random):
@ -91,6 +90,6 @@ def generate(random):
def grade(random, key): def grade(random, key):
n, e, deez, salt = get_problem(random) n, e, deez, salt = get_problem(random)
if key.find("%s_%s" % (flag, salt)) >= 0: if key.find("%s%s" % (flag, salt)) >= 0:
return True, "Correct!" return True, "Correct!"
return False, "Nope." return False, "Nope."