# Xor Encryption
#
# Pardon the following poor explanations
# To encrypt the code simply put your code into the code variable and run it
# To decrypt the encrypted code simply put your encrypted code into the code variable
# In order to decrypt the encrypted code the key must be the same key used to encrypt it
# Diagram:
#
# encrypting:
# code: "print(1)" ---|
# |--- "\x03\x17\n\x1C\x11\\\x01\x19"
# key: "secret00" ---|
#
# decrypting:
# encrypt: "\x03\x17\n\x1C\x11\\\x01\x19" -|
# |--- "print(1)"
# key: "secret00" -------------------------|
def xorEncryption(key, code):
if len(key) < len(code):
while len(key) < len(code):
key += key
return b"".join([chr(code[i] ^ key[i]).encode() for i in range(len(code))])
code = b"""
# Code Here
"""
key = b"""
# Key Here
"""
encrypt = xorEncryption(key, code)
decrypt = xorEncryption(key, encrypt)
print(
f"code: {code}",
f"key: {key}",
f"encrypt: {encrypt}",
f"decrypt: {decrypt}",
sep='\n')