import base64 import crypto input = "49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d" print "Hex input:" print input print "Plaintext:" print crypto.hex_to_str(input) print "Encoded" print crypto.hex_to_base64(input)
import crypto input = crypto.hex_to_str("1b37373331363f78151b7f2b783431333d78397828372d363c78373e783a393b3736") key, score, string = crypto.break_byte_key_english(input) print "Key: '{}' ({}): {}".format(chr(key), score, string)
import crypto best = "" bestkey = "" bestscore = 0.0 with open('data/4.txt', 'r') as f: for line in f: ct = crypto.hex_to_str(line.rstrip()) for k in range(256): s = crypto.xorstring_key(ct, chr(k)) score = crypto.score_english(s) if score > bestscore: best = s bestkey = k bestscore = score print "Key: '{}' ({}): {}".format(chr(bestkey), bestscore, best)