Very basic XOR encryption
November 10, 2024
I like XOR encryption since it is super basic and my grades in discrete math were not the best. Here is a very simple example on how to use XOR encryption in python:
secret = 'guara.tech is the best'.encode('utf-8')
key = 'mysuperstrongkeywillneverbebrokenorforgotten'.encode('utf-8')
encode = lambda x, y : bytes(map(lambda a, b : a ^ b, x, y))
cypher = encode(secret, key)
decoded = encode(cypher, key)
print('cypher: ', cypher)
print('secret: ', secret)
print('decoded: ', decoded)
The disadvantage is that your key needs to be as large as your secret 💀