def challenge_2(): hex_string = "1c0111001f010100061a024b53535009181c" xor_string = "686974207468652062756c6c277320657965" expected_result = "746865206b696420646f6e277420706c6179" plaintext_bytes, xor_bytes = map(crypto.hex_to_bytes, (hex_string, xor_string)) result_bytes = crypto.flexible_xor(plaintext_bytes, xor_bytes) result = crypto.bytes_to_hex(result_bytes) test(expected_result, result)
def challenge_5(): plaintext = "Burning 'em, if you ain't quick and nimble\nI go crazy when I hear a cymbal" xor_key = "ICE" plaintext_bytes = crypto.string_to_bytes(plaintext) xor_bytes = crypto.string_to_bytes(xor_key) result_bytes = crypto.flexible_xor(plaintext_bytes, xor_bytes) result = crypto.bytes_to_hex(result_bytes) print("Result: %s" % result)