dg-npm-templates
Version:
Npx generator for react app dependency creation by digite
20 lines (14 loc) • 492 B
JavaScript
const crypto = require("crypto");
const ENC_KEY = "eThWmZq4t7w!z%C*F)J@NcRfUjXn2r5u";
const IV = "9&_a7Ty7HXsSK&%!";
const encrypt = val => {
const cipher = crypto.createCipheriv("aes-256-gcm", ENC_KEY, IV);
return cipher.update(val, "utf8", "base64") + cipher.final("base64");
};
const decrypt = encrypted => {
const decipher = crypto.createDecipheriv("aes-256-gcm", ENC_KEY, IV);
return decipher.update(encrypted, "base64", "utf8");
};
module.exports = {
encrypt, decrypt
};