mirror of
https://github.com/mohamadihsan/topuponline.git
synced 2026-12-06 23:36:28 +00:00
24 lines
515 B
JavaScript
24 lines
515 B
JavaScript
const CryptoJS = require('crypto-js');
|
|
|
|
// ENCRYPT TEXT
|
|
const encryptText = (text) => {
|
|
try {
|
|
return CryptoJS.AES.encrypt(text, process.env.SECRET_KEY).toString()
|
|
} catch (error) {
|
|
return error.message;
|
|
}
|
|
}
|
|
|
|
// DECRYPT TEXT
|
|
const decryptText = (cipherText) => {
|
|
try {
|
|
return CryptoJS.AES.decrypt(cipherText, process.env.SECRET_KEY).toString(CryptoJS.enc.Utf8)
|
|
} catch (error) {
|
|
return error.message;
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
encryptText,
|
|
decryptText,
|
|
} |