Skip to content

Instantly share code, notes, and snippets.

@JABirchall
Created November 1, 2014 10:18
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 JABirchall/dc50a9ecba415bce2c99 to your computer and use it in GitHub Desktop.
Save JABirchall/dc50a9ecba415bce2c99 to your computer and use it in GitHub Desktop.
var Key3 = "sRnoTpMqcHfB94Kbd8gCDxEXtFiG2u6v$O%PQSl&U7YwZa3hLNryIz01JWAejkV52";
var Key2 = "CesDxEcFl'U7YwZpMqrXtBu6v:kV5mRnyIiG2HjfNO.PKSzLaQbd8gAh0oT1JW343";
var Key1 = "bcdefgEFGHIJKLhijklmnopqrsABCDP12345uvw6789+MNO/=QRSTUVWXYZatxyz4";
function key2Lock(ipc) {
var opo = "",
chr1, chr2, chr3, enc1, enc2, enc3, enc4, i = 0;
do {
chr1 = ipc.charCodeAt(i++);
chr2 = ipc.charCodeAt(i++);
chr3 = ipc.charCodeAt(i++);
enc1 = chr1 >> 2;
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
enc4 = chr3 & 63;
if (isNaN(chr2)) {
enc3 = enc4 = 64
} else if (isNaN(chr3)) {
enc4 = 64
}
opo = opo + Key3.charAt(enc1) + Key3.charAt(enc2) + Key3.charAt(enc3) + Key3.charAt(enc4)
} while (i < ipc.length);
return opo
}
function e6(ipc) {
var opo = "",
chr1, chr2, chr3, enc1, enc2, enc3, enc4, i = 0;
do {
chr1 = ipc.charCodeAt(i++);
chr2 = ipc.charCodeAt(i++);
chr3 = ipc.charCodeAt(i++);
enc1 = chr1 >> 2;
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
enc4 = chr3 & 63;
if (isNaN(chr2)) {
enc3 = enc4 = 64
} else if (isNaN(chr3)) {
enc4 = 64
}
opo = opo + Key1.charAt(enc1) + Key1.charAt(enc2) + Key1.charAt(enc3) + Key1.charAt(enc4)
} while (i < ipc.length);
return opo
};
function d6(ipc) {
var opo = "",
chr1, chr2, chr3, enc1, enc2, enc3, enc4, i = 0;
ipc = ipc.replace(/[^A-Za-z0-9\%\$\&]/g, "");
do {
enc1 = Key1.indexOf(ipc.charAt(i++));
enc2 = Key1.indexOf(ipc.charAt(i++));
enc3 = Key1.indexOf(ipc.charAt(i++));
enc4 = Key1.indexOf(ipc.charAt(i++));
chr1 = (enc1 << 2) | (enc2 >> 4);
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
chr3 = ((enc3 & 3) << 6) | enc4;
opo = opo + String.fromCharCode(chr1);
if (enc3 != 64) {
opo = opo + String.fromCharCode(chr2)
}
if (enc4 != 64) {
opo = opo + String.fromCharCode(chr3)
}
} while (i < ipc.length);
return opo
};
function l900(ipc) {
var opo = "",
chr1, chr2, chr3, enc1, enc2, enc3, enc4, i = 0;
ipc = encodeURIComponent(ipc);
do {
chr1 = ipc.charCodeAt(i++);
chr2 = ipc.charCodeAt(i++);
chr3 = ipc.charCodeAt(i++);
enc1 = chr1 >> 2;
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
enc4 = chr3 & 63;
if (isNaN(chr2)) {
enc3 = enc4 = 64
} else if (isNaN(chr3)) {
enc4 = 64
}
opo = opo + Key2.charAt(enc1) + Key2.charAt(enc2) + Key2.charAt(enc3) + Key2.charAt(enc4)
} while (i < ipc.length);
return opo
};
function u900(ipc) {
var opo = "",
chr1, chr2, chr3, enc1, enc2, enc3, enc4, i = 0;
ipc = ipc.replace(/[^A-Za-z0-9\.\:\']/g, "");
do {
enc1 = Key2.indexOf(ipc.charAt(i++));
enc2 = Key2.indexOf(ipc.charAt(i++));
enc3 = Key2.indexOf(ipc.charAt(i++));
enc4 = Key2.indexOf(ipc.charAt(i++));
chr1 = (enc1 << 2) | (enc2 >> 4);
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
chr3 = ((enc3 & 3) << 6) | enc4;
opo = opo + String.fromCharCode(chr1);
if (enc3 != 64) {
opo = opo + String.fromCharCode(chr2)
}
if (enc4 != 64) {
opo = opo + String.fromCharCode(chr3)
}
} while (i < ipc.length);
opo = decodeURIComponent(opo);
return opo
};
function ce(mz) {
mz = e6(mz);
var strArray = new Array(),
fromChar = new Array();
for (var x = 0; x < mz.length; x++) {
strArray[x] = mz.charAt(x)
}
fromChar['a'] = '61';
fromChar['b'] = '62';
fromChar['c'] = '63';
fromChar['d'] = '64';
fromChar['e'] = '65';
fromChar['f'] = '66';
fromChar['g'] = '67';
fromChar['h'] = '68';
fromChar['i'] = '69';
fromChar['j'] = '6A';
fromChar['k'] = '6B';
fromChar['l'] = '6C';
fromChar['m'] = '6D';
fromChar['n'] = '6E';
fromChar['o'] = '6F';
fromChar['p'] = '70';
fromChar['q'] = '71';
fromChar['r'] = '72';
fromChar['s'] = '73';
fromChar['t'] = '74';
fromChar['u'] = '75';
fromChar['v'] = '76';
fromChar['w'] = '77';
fromChar['x'] = '78';
fromChar['y'] = '79';
fromChar['z'] = '7A';
fromChar['A'] = '41';
fromChar['B'] = '42';
fromChar['C'] = '43';
fromChar['D'] = '44';
fromChar['E'] = '45';
fromChar['F'] = '46';
fromChar['G'] = '47';
fromChar['H'] = '48';
fromChar['I'] = '49';
fromChar['J'] = '4A';
fromChar['K'] = '4B';
fromChar['L'] = '4C';
fromChar['M'] = '4D';
fromChar['N'] = '4E';
fromChar['O'] = '4F';
fromChar['P'] = '50';
fromChar['Q'] = '51';
fromChar['R'] = '52';
fromChar['S'] = '53';
fromChar['T'] = '54';
fromChar['U'] = '55';
fromChar['V'] = '56';
fromChar['W'] = '57';
fromChar['X'] = '58';
fromChar['Y'] = '59';
fromChar['Z'] = '5A';
fromChar['0'] = '30';
fromChar['1'] = '31';
fromChar['2'] = '32';
fromChar['3'] = '33';
fromChar['4'] = '34';
fromChar['5'] = '35';
fromChar['6'] = '36';
fromChar['7'] = '37';
fromChar['8'] = '38';
fromChar['9'] = '39';
fromChar['*'] = '2A';
fromChar['/'] = '2F';
fromChar['_'] = '5F';
fromChar['+'] = '2B';
fromChar['-'] = '2D';
fromChar['@'] = '40';
fromChar['.'] = '2E';
for (var x = 0; x < strArray.length; x++) {
strArray[x] = (strArray[x] == escape(strArray[x])) ? (fromChar[strArray[x]]) : escape(strArray[x]).replace(/%/, '')
}
return strArray.join('')
}
function e900(mz, kp) {
if (kp.length < 4) {
window.alert('The key must be at least 4 characters long');
return mz
};
kp = key2Lock(kp);
mz = encodeURIComponent(mz);
var kn = new Array(),
os = '',
oo = new Array('+=', '/=', '-=', '*= 0.01 *');
for (var x = 0; x < kp.length; x++) {
kn[x] = parseInt('0x' + ce(kp.charAt(x)))
}
for (var x = 0, y = ''; x < mz.length; x += Math.round(kp.length / 5), y = ' ') {
var rt = parseInt('0x' + ce(mz.substr(x, Math.round(kp.length / 5))));
if (isNaN(rt)) {
window.alert('Encrypton failed.');
return mz
}
for (var z = 0; z < kp.length; z++) {
eval('rt ' + oo[z % 1] + ' ' + kn[z] + ';')
}
os += y + rt
};
return os
};
function d900(mz, kp) {
if (kp.length < 4) {
window.alert('The key must be at least 4 characters long');
return mz
}
kp = key2Lock(kp);
var kn = new Array(),
os = mz.split(' '),
os2 = '',
oo = new Array('-=', '*=', '+=', '/= 0.01 *');
for (var x = 0; x < kp.length; x++) {
kn[x] = parseInt('0x' + ce(kp.charAt(x)))
}
for (var x = 0; x < os.length; x++) {
os[x] = parseFloat(os[x]);
for (var z = kp.length - 1; z >= 0; z--) {
eval('os[x] ' + oo[z % 1] + ' ' + kn[z] + ';')
}
os[x] = dechex(Math.round(os[x]))
}
os = os.join('');
for (x = 0; x < os.length; x += 2) {
os2 += unescape('%' + os.substr(x, 2))
}
os2 = d6(os2);
os2 = decodeURIComponent(os2);
return os2
};
function dechex(om) {
var hxc = new Array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'),
oup = '',
d;
for (var x = om; x > 0; x = (x - (x % 16)) / 16) {
oup = hxc[x % 16] + '' + oup
}
if (oup.length % 2) {
oup = '0' + oup
}
return oup
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment