CryptoJS JSON Encryption and Decryption
This module provides functions for encrypting and decrypting JSON data using the CryptoJS library.
Installation
npm i react-npm-encrypt-decrypt
Usage
const { decryptJSONHandler, encryptJSONHandler } = require('react-npm-encrypt-decrypt');
// Your encryption key and initialization vector (IV)
const AES_ENC_SECRET_KEY = 'your-secret-key';
const AES_ENC_IV = 'your-initialization-vector';
// Your JSON data to be encrypted
const jsonData = { key1: 'value1', key2: 'value2' };
// Encrypt JSON data
const encryptedData = encryptJSONHandler(JSON.stringify(jsonData), AES_ENC_SECRET_KEY, AES_ENC_IV);
console.log('Encrypted Data:', encryptedData);
// Decrypt JSON data
const decryptedData = decryptJSONHandler(encryptedData, AES_ENC_SECRET_KEY, AES_ENC_IV);
console.log('Decrypted Data:', decryptedData);