(data, key)
| 3 | KEY = "privatekeyforxorencryptionfunction" |
| 4 | |
| 5 | def xor(data, key): |
| 6 | |
| 7 | key = str(key) |
| 8 | l = len(key) |
| 9 | output_str = "" |
| 10 | |
| 11 | for i in range(len(data)): |
| 12 | current = data[i] |
| 13 | current_key = key[i % len(key)] |
| 14 | output_str += chr(ord(current) ^ ord(current_key)) |
| 15 | |
| 16 | return output_str |
| 17 | |
| 18 | def printCiphertext(ciphertext): |
| 19 | print('{ 0x' + ', 0x'.join(hex(ord(x))[2:] for x in ciphertext) + ' };') |