Exemplo n.º 1
0
def challenge_3():
	hex_string = "1b37373331363f78151b7f2b783431333d78397828372d363c78373e783a393b3736"
	
	cipher_bytes = crypto.hex_to_bytes(hex_string)
	candidate_bytes = [[byte] for byte in range(0, 255)]

	result = crypto.brute_single_xor(cipher_bytes, candidate_bytes)
	print("Plaintext: %s" % result[1])	
Exemplo n.º 2
0
def challenge_4():
	input_file = "1-4.txt"
	candidate_bytes = [[byte] for byte in range(0, 255)]
	best_result = (None, None, 0)

	for line in open(input_file).readlines():
		line = line.strip()
		if not line:
			continue
		cipher_bytes = crypto.hex_to_bytes(line)
		result = crypto.brute_single_xor(cipher_bytes, candidate_bytes)
	
		if result[1] and result[2] > best_result[2]:
			best_result = result
		
	print("Plaintext: %s" % best_result[1])