Skip to content

Instantly share code, notes, and snippets.

@quilime
Last active February 9, 2017 00:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save quilime/1b82315870514eefc57b1dd93a74d4b3 to your computer and use it in GitHub Desktop.
Save quilime/1b82315870514eefc57b1dd93a74d4b3 to your computer and use it in GitHub Desktop.
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