Created
January 31, 2018 03:32
-
-
Save ril3y/501020a4e3923f3422253a5501eff6fe to your computer and use it in GitHub Desktop.
Simple Javascript String XOR utility
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var xor_str = function(s,K) | |
{ | |
c = ''; | |
for(i=0; i<str.length; i++) { | |
for(ik=0; ik<K.length; ik++){ | |
c += String.fromCharCode(str[i].charCodeAt(0).toString(10) ^ key.charCodeAt(0).toString(10)); // XORing with letter 'K' | |
} | |
} | |
return c; | |
} |
dartandrevinsky
commented
Nov 10, 2020
const xorStrings = (str1, str2) => {
str1 = str1.split("");
str2= str2.split("");
let betw=0;
for(let i = 0; i<str1.length; i++)
betw=str1[i].charCodeAt(0)^str2[i].charCodeAt(0)^betw;
return betw == 0 ? true : false;
};
@TimofeyOpal please use markdown
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment