JSFiddle - React, Tailwind, and code Playground

XOR encode/decode

by Csaba Hellinger

HTML

<p>Simple XOR encode/decode for MXDXDK.</p>
<p>See the console for results.</p>

JavaScript

var str = "some-text";
var key = 194;

// encode
var index, arr = [];
for (index = 0; index < str.length; index += 1) {
    arr.push(str.charCodeAt(index) ^ key);
}

// decode
var text = "";
for (index = 0; index < arr.length; index += 1) {
    text += String.fromCharCode(arr[index] ^ key);
}

console.clear();
console.log('encoded:');
console.log(JSON.stringify(arr));
console.log('decoded:')
console.log(text);