GDBrowser/classes/XOR.js
GDColon 60da852534 A whole lotta hoopla
CHANGELOG:
- Profile posts! This one is long overdue but... yeah! You can now leave profile posts, and drop likes on them as well!
- Classes folder! It's a folder... for classes! Don't ask me to explain what a class is, because I'm still not sure myself
- Le Level Class has arrived! Instead of parsing level data in three different files, the level class has stepped up to do the dirty work. (thanks to memimoe for helping)
- Renamed generate.css to iconkit.css, and deleted soon.css because it's ugly
- Removed 404 redirect when trying to view an asset that doesn't exist
- Updated readme to get with the times
- Removed Herobrine
2019-12-15 19:11:35 -05:00

62 lines
No EOL
2.4 KiB
JavaScript

//////////////////////////////////////////////////////////////////////////////////////////
// //
// ******** ********** ******* ** ******** **** ** //
// **////// /////**/// **/////** /** /**///// /**/** /** //
// /** /** ** //**/** /** /**//** /** //
// /********* /** /** /**/** /******* /** //** /** //
// ////////** /** /** /**/** /**//// /** //**/** //
// /** /** //** ** /** /** /** //**** //
// ******** /** //******* /********/********/** //*** //
// //////// // /////// //////// //////// // /// //
// //
//////////////////////////////////////////////////////////////////////////////////////////
//Stolen from https://github.com/fakemancat/geometry-dash-api/blob/master/classes/XOR.js because I am stupid.
module.exports = class XOR {
// Base64 functions
b64from(text) {
return Buffer.from(text, 'base64').toString('utf-8');
}
b64to(text) {
return Buffer.from(text).toString('base64');
}
// Xor functions
chr(ascii) {
return String.fromCodePoint(ascii);
}
text2ascii(input) {
return String(input).split('').map(letter => letter.charCodeAt());
}
cipher(data, key) {
key = this.text2ascii(key);
data = this.text2ascii(data);
let keysize = key.length;
let input_size = data.length;
let cipher = '';
for (let i = 0; i < input_size; i++) {
cipher += this.chr(data[i] ^ key[i % keysize]);
}
return cipher;
}
encrypt(password, key = 37526) {
let encode = this.cipher(password, key);
encode = Buffer.from(encode).toString('base64');
encode = encode
.replace(/\//g, '_')
.replace(/\+/g, '-');
return encode;
}
decrypt(gjp, key = 37526) {
let decode = gjp
.replace(/_/g, '/')
.replace(/-/g, '+');
decode = Buffer.from(decode, 'base64').toString();
decode = this.cipher(decode, key);
return decode;
}
};