refactor/support multiple discord guilds with 1 nitrado server each + better handling for NitradoAPI

This commit is contained in:
SowinskiBraeden committed 2024-04-04 20:11:48 -07:00
1 parent 71d03ffa72
commit 55c8a9ee7f
33 files changed
+888 -1028

No files matched your search

+19
View File
@@ -0,0 +1,19 @@
const crypto = require('crypto');
module.exports = {
encrypt: (data, EncryptionMethod, Key, EncryptionIV) => {
const cipher = crypto.createCipheriv(EncryptionMethod, Key, EncryptionIV)
return Buffer.from(
cipher.update(data, 'utf8', 'hex') + cipher.final('hex')
).toString('base64') // Encrypts data and converts to hex and base64
},
decrypt: (data, EncryptionMethod, Key, EncryptionIV) => {
const buff = Buffer.from(data, 'base64')
const decipher = crypto.createDecipheriv(EncryptionMethod, Key, EncryptionIV)
return (
decipher.update(buff.toString('utf8'), 'hex', 'utf8') +
decipher.final('utf8')
) // Decrypts data and converts to utf8
}
}