def main(): p, q = find_p_q() #1 print 'Moving on..' n = p * q # 2 et = euler(p, q) # 3 e = (2**16) + 1 # 4 d = mulinv(e, et) #5 #6 NA """ Test values """ m1 = 8049 encm1 = rypto.mod_exp(m1, e, n) decm1 = rypto.mod_exp(encm1, d, n) print 'Checking m1 is decrypted correctly' print m1, decm1, m1 == decm1 m2 = 'Hi this is short' m2encoded = int(m2.encode("hex"), 16) encm2 = rypto.mod_exp(m2encoded, e, n) decm2 = rypto.mod_exp(encm2, d, n) hexad = rypto.standard(hex(decm2)) decm2b = hexad[:-1].decode("hex") print 'Checking m2 is decrypted correctly' print m2, decm2b, m2 == decm2b
def main(): e = (2**16) + 1 client = rypto.rsa(e) #RSA class secret = 'secret text' #Secret text (hidden from attacker) enc_sec = client.enc(secret) #Encrypted text (Known by attacker) known = pow(30, e) #Attacker picks a known value of their own hidden = (known * enc_sec) % client.n #Attacker hides value using multiplication dec_hidden = client.dec( hidden) #Decrypt attack value (passes check of server) x = int(dec_hidden.encode("hex"), 16) / 30 #Divide attacker known value x = rypto.standard(hex(x)).decode("hex") #Convert and such print x
def main(): N = 402394248802762560784459411647796431108620322919897426002417858465984510150839043308712123310510922610690378085519407742502585978563438101321191019034005392771936629869360205383247721026151449660543966528254014636648532640397857580791648563954248342700568953634713286153354659774351731627683020456167612375777 e1 = 3 e2 = 0x10001 c1 = 4020137574131575546540268502595841326627069047574502831387774931737219358054228401772587980633053000 c2 = 170356929377044754324767086491413709789303946387160918939626824506821140429868670769571821346366209258416985269309515948776691067548265629489478628756185802183547222688698309731374342109385922509501909728895585636684978295199882599818258590851085977232207148101448845575681189389906429149193460620083999406237 g, x, y = rypto.egcd(e1, e2) #Euclidean algorightm i = rypto.mulinv(c2, N) #multiplicative inverse of C2 because y is -1 test = (rypto.mod_exp(c1, x, N) * rypto.mod_exp(i, -y, N)) % N #plain = (c1^a) * (i^-b) %N answer = rypto.standard(hex(test)).decode("hex") print answer
def main(): e = 3 print 'Setting up server 1' s0 = rypto.rsa(e) print 'Setting up server 2' s1 = rypto.rsa(e) print 'Setting up server 3' s2 = rypto.rsa(e) m = 'Trying a different message' c = solve(s0, s1, s2, m) cubed = int(round(c**(1. / 3))) hexad = rypto.standard(hex(cubed)) print hexad.decode("hex")
#!/usr/bin/env python import rypto from pprint import pprint if __name__ == "__main__": #a = "We didn't start the fire, It was always burning, Since the world's been turning, We didn't start the fire, No we didn't light it, But we tried to fight it" a = raw_input("Please enter a phrase to encrpt: ") b = raw_input("Please enter a key to encrypt with:") #Turning the strings into a list of hex bytes line = rypto.a2hex(a) key = rypto.a2hex(b) #Pretty printing these lists #pprint(key #pprint(line) #print("%s repeatedly xored with %s equals: \n" % (' '.join(key), ' '.join(line))) answer = rypto.xor(line,key) print rypto.standard(''.join(answer))
#Main Function if __name__ == "__main__": #File to b64 to hex hx = short_open("w4p1.txt") #Filename = w4p1.txt #IV iv = '00000000000000000000000000000000' #iv #Key (In ascii) ascii_key = 'NO PAIN NO GAIN!' #key in Ascii, DONT CHANGE #Block size bs = 128 #Padding block size #Convert ascii key into hex string hex_string_key = ascii_key.encode( "hex") #AESKeyToChange (Replace everything after the '='s) hex_string_key = rypto.standard( hex_string_key) #Standardizes key to best of ability """ Please read assumption about this key. If all assumptions are thrown away, remove second hex_string_key line and end with first ascii-like input with encoding hex_string_key as hex. That should work. " ".encode("hex") """ #Magic print prep_cbc(hx, hex_string_key, iv, bs)