XOR Encryption

Googling about XOR encryption reveals that you bitwise XOR each letter of a key with the letter of the secret and then take the resultant ASCII as your encrypted secret.

An interesting property about XOR is that if A ^ B = C then A ^ C = B.

This implies that you can get the encoding key if you get the plaintext message and the encrypted message.

Here is a simple python script that does the job

#!/usr/bin/python3


def xor(string1, string2):
    return_val = ""
    if len(string1) == len(string2):
        for i in range(len(string1)):
            return_val += chr(ord(string1[i]) ^ ord(string2[i]))
        return return_val
    return None


message = "ctfZero{not_the_key}"
encoded = "%RV($Q/^KE5iAT8-CIA%"

key = xor(message, encoded)

final_encoded = "%RV($Q/^QE5WYP$-[YK%"

print(xor(key, final_encoded))