Beispiel #1
0
 def test_decode_hex(self):
     """Test decoding of hex string."""
     self.assertEqual(255, list(set_1.decode_hex('ff'))[0])
     self.assertEqual(171, list(set_1.decode_hex('ab'))[0])
     self.assertEqual(5, list(set_1.decode_hex('5'))[0])
     self.assertEqual(15, list(set_1.decode_hex('f'))[0])
     self.assertEqual([73, 39], list(set_1.decode_hex('4927')))
     self.assertEqual([15, 59, 172], list(set_1.decode_hex('0F3BAC')))
     self.assertEqual([202, 254, 186, 190],
                      list(set_1.decode_hex('CAFEBABE')))
def decrypt_hex(hex_string):
    """Decrypt the hex encoded string."""
    return decrypt(decode_hex(hex_string))
def xor_hex(hex_1, hex_2):
    """XOR two fixed length hex strings."""
    return encode_hex(xor(decode_hex(hex_1), decode_hex(hex_2)))