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
Add the following lines to your .env file:
REACT_APP_TECHUS_AES_ENC_SECRET_KEY="your-secret-key"
REACT_APP_TECHUS_AES_ENC_IV="your-initialization-vector"
Implement the techusDecryptHandler, and techusEncryptHandler to your code like
const { decryptJSONHandler, encryptJSONHandler } = require('react-npm-encrypt-decrypt');
// Decrypt JSON data from a response
const responseData = techusDecryptHandler(response.data.edata);
console.log('Decrypted Data:', responseData);
console.log(JSON.parse(responseData));
// Encrypt data before sending
const dataToEncrypt = { someKey: 'someValue' };
const encryptedRequestData = techusEncryptHandler(JSON.stringify(dataToEncrypt));
console.log('Encrypted Request Data:', encryptedRequestData);