react-npm-encrypt-decrypt
Advanced tools
Comparing version
{ | ||
"name": "react-npm-encrypt-decrypt", | ||
"version": "1.0.47", | ||
"version": "1.0.48", | ||
"description": "The package used to encrypt and decrypt the data dynamically with keys.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -31,6 +31,6 @@ # CryptoJS JSON Encryption and Decryption | ||
const { decryptJSONHandler, encryptJSONHandler } = require('react-npm-encrypt-decrypt'); | ||
const { techusDecryptHandler, techusEncryptHandler } = require('react-npm-encrypt-decrypt'); | ||
// Decrypt JSON data from a response | ||
const responseData = await techusDecryptHandler(response.data.edata); | ||
const responseData = techusDecryptHandler(encData); | ||
@@ -42,12 +42,5 @@ console.log('Decrypted Data:', responseData); | ||
const dataToEncrypt = { someKey: 'someValue' }; | ||
const encryptStr = techusEncryptHandler(JSON.stringify(dataToEncrypt)); | ||
console.log('enc Data ', encryptStr) | ||
encryptStr.then((response) => { | ||
if (response) { | ||
console.log(response); | ||
return response; | ||
const encryptStr = techusEncryptHandler(dataToEncrypt); | ||
console.log('enc Data str', encryptStr) | ||
} | ||
}); | ||
``` |
@@ -45,2 +45,3 @@ // const CryptoJS = require('crypto-js'); | ||
let storageKey = ''; | ||
let storedValue = 0; | ||
@@ -50,6 +51,5 @@ function techusEncryptHandler(value, AES_ENC_SECRET_KEY = SKEY, AES_ENC_IV = IV) { | ||
if (typeof localStorage !== 'undefined') { | ||
let storedValue = localStorage.getItem('yourStorageKey'); | ||
storedValue = localStorage.getItem('yourStorageKey'); | ||
console.log('storedValue',storedValue); | ||
if (!storedValue) { | ||
if (storedValue == 0) { | ||
const key = CryptoJS.enc.Utf8.parse(AES_ENC_SECRET_KEY); | ||
@@ -81,8 +81,6 @@ const iv = CryptoJS.enc.Utf8.parse(AES_ENC_IV); | ||
function apicall(AES_ENC_SECRET_KEY, AES_ENC_IV) { | ||
async function apicall(AES_ENC_SECRET_KEY, AES_ENC_IV) { | ||
try { | ||
const res = keysService(AES_ENC_SECRET_KEY, AES_ENC_IV); | ||
const res = await keysService(AES_ENC_SECRET_KEY, AES_ENC_IV); | ||
console.log('res', res); | ||
if (res && res.data.is_valid === 1) { | ||
storageKey = res.data.storage_key; | ||
@@ -92,3 +90,2 @@ localStorage.setItem('yourStorageKey', storageKey); | ||
} | ||
} catch (error) { | ||
@@ -95,0 +92,0 @@ console.error('Error during API call:', error.message); |
10736
-1.8%214
-0.47%44
-13.73%