XOR Cipher

Published by persolut in

In XOR Cipher, encoding is done by an XOR operation on two given strings. If the strings are of different lengths then the output should be the length of the shorter string. Cut the length of the longer string to the same size as the smaller string before XOR operation.

Given two strings of msg1 and msg2, return the encoded message.

Examples

XORCipher("11", "22") ➞ "33"
// 11 XOR 22 = 33

XORCipher("1020304", "403201") ➞ "501231"

XORCipher("c611d9bdd9de38b9eb", "23a0745505d4d25494") ➞ "e5b1ade8dc0aeaed7f"

Notes

A hint is in the Comments section.

Watch a quick demo on how Edabit works.