To encrypt and decrypt data, simply use encrypt () and decrypt () function from an instance of crypto-js. Node.js (Install) Requirements: 1. Node.js 2. npm (Node.js package manager) 3. npm install crypto-js npm install crypto - js Usage - Step 1 - Import var CryptoJS = require ( "crypto-js" ); Step 2 - Encrypt // Encrypt var ciphertext = CryptoJS . AES . encrypt ( JSON . stringify ( data ), 'my-secret-key@123' ). toString (); Step 3 -Decrypt // Decrypt var bytes = CryptoJS . AES . decrypt ( ciphertext , 'my-secret-key@123' ); var decryptedData = JSON . parse ( bytes . toString ( CryptoJS . enc . Utf8 )); As an Example, import React from 'react' ; import './App.css' ; //Including all libraries, for access to extra methods. var CryptoJS = require ( "crypto-js" ); function App () { var data
Interview Questions Answers | Angular, React, JavaScript, Java, PHP, SQL, C#, Vue, NodeJs, TypeScript