GDBrowser/classes/XOR.js
GDColon 351f1c0ad8 Lots of QOL + Icon Kit improvements
- added an optional col3 to icon kit
- added an options menu to the icon kit
- added a random button to the icon kit
- added a proper popup for the icon kit's 'steal icon' button
- redid the buttons on the icon kit
- tripled icon cache duration
- rewrote and minified the XOR class
- idk some other fun stuff
2020-09-22 18:37:21 -04:00

5 lines
No EOL
457 B
JavaScript

module.exports = class XOR {
xor(str, key) { return String.fromCodePoint(...str.split('').map((char, i) => char.charCodeAt(0) ^ key.toString().charCodeAt(i % key.toString().length))) }
encrypt(str, key = 37526) { return Buffer.from(this.xor(str, key)).toString('base64').replace(/\//g, '_').replace(/\+/g, '-'); }
decrypt(str, key = 37526) { return this.xor(Buffer.from(str.replace(/\//g, '_').replace(/\+/g, '-'), 'base64').toString(), key) }
}