Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import crypto from 'crypto';
- import { SECRET_KEY_AES, IV } from '../configs/keys';
- export const encryptAes = data => {
- // const hashResult = await new Promise((resolve, reject) => {
- if (data) {
- const cipher = crypto.createCipheriv('aes-256-cbc', SECRET_KEY_AES, IV);
- let encrypted = cipher.update(data, 'utf8', 'base64');
- encrypted += cipher.final('base64');
- return encrypted;
- }
- return null;
- // // });
- // return hashResult;
- };
- export const decryptAes = data => {
- // const hashResult = await new Promise((resolve, reject) => {
- const cipher = crypto.createDecipheriv('aes-256-cbc', SECRET_KEY_AES, IV);
- const decrypted = cipher.update(data, 'utf8', 'base64');
- return decrypted;
- // // });
- // return hashResult;
- };
Add Comment
Please, Sign In to add comment