Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
const key = 'z){@UWzw*+TRt7Xu3c-(qL_.~MNCN3prv(!{'; // secret
const encode = function encode(key, data) {
return new Buffer(xorStrings(key, data), 'utf8').toString('base64');
}
const decode = function decode(key, data) {
data = new Buffer(data, 'base64').toString('utf8');
return xorStrings(key, data);
}
const xorStrings = function xorStrings(key, input) {
let output = '';
for (var i = 0; i < input.length; i++) {
var c = input.charCodeAt(i);
var k = key.charCodeAt(i % key.length);
output += String.fromCharCode(c ^ k);
}
return output;
}
const uuid = process.argv[2];
const p = uuid.split('-');
const uuidstr = `${p[4]}.${p[2]}.${p[1]}.${p[3]}.${p[0]}`;
const input = uuidstr;
console.log('uuid:', uuid);
console.log('modd:', input);
const encoded = encode(key, input);
const decoded = decode(key, encoded);
console.log(`encoded: '${encoded}'`);
console.log(`decoded: '${decoded}'`);
// const getKey = decode(input, encoded);
// console.log("getKey:", getKey);
/*
$ node uuidObfuscation.js `uuidgen`
uuid: 00BBA5ED-D9CA-452B-80E0-3A5048A4B626
modd: 3A5048A4B626.452B.D9CA.80E0.00BBA5ED
encoded: 'SWhOcGFvO0NoHWZkWgNtR3FNaREyDXEWTgh+bX4DMjA3HWQ/'
decoded: '3A5048A4B626.452B.D9CA.80E0.00BBA5ED'
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.