react-npm-encrypt-decrypt

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-npm-encrypt-decrypt - npm Package Compare versions

Comparing version

to
1.0.59

@@ -13,34 +13,34 @@ const {techusEncryptHandler,apicall} = require('./techus-libraries/techus-encrypt');

(async () => {
const jsonData = {
"device":{
"api_version":"1",
"app_version_code":"1",
"app_version_number":"1.0",
"browser":"Chrome",
"device_fcm_token":"",
"device_key":"dcb6354f419c62ca4e61",
"device_manufacture":"Chrome",
"device_model":"122",
"device_os":"Windows",
"device_os_version":"web",
"ip_address":"127.0.0.1",
"locale":"en",
"source":"web",
"time_zone":"Asia/Calcutta::+05:30"
},
"user":{
"confirm_password":"1664cfb254d6d6ebf0ee3ce386631c2f26043e9daa48d53cae174681a7ad54eb",
"email_address":"lsmanasa+80@compindia.com",
"full_name":"Sai Manasa",
"org_id":45,
"password":"8776f108e247ab1e2b323042c049c266407c81fbad41bde1e8dfc1bb66fd267e",
"phone_number":"786221589"
}
}
// (async () => {
// const jsonData = {
// "device":{
// "api_version":"1",
// "app_version_code":"1",
// "app_version_number":"1.0",
// "browser":"Chrome",
// "device_fcm_token":"",
// "device_key":"dcb6354f419c62ca4e61",
// "device_manufacture":"Chrome",
// "device_model":"122",
// "device_os":"Windows",
// "device_os_version":"web",
// "ip_address":"127.0.0.1",
// "locale":"en",
// "source":"web",
// "time_zone":"Asia/Calcutta::+05:30"
// },
// "user":{
// "confirm_password":"1664cfb254d6d6ebf0ee3ce386631c2f26043e9daa48d53cae174681a7ad54eb",
// "email_address":"lsmanasa+80@compindia.com",
// "full_name":"Sai Manasa",
// "org_id":45,
// "password":"8776f108e247ab1e2b323042c049c266407c81fbad41bde1e8dfc1bb66fd267e",
// "phone_number":"786221589"
// }
// }
const encryptedData = await techusEncryptHandler(JSON.stringify(jsonData));
console.log('Encrypted Data:', encryptedData);
// const encryptedData = await techusEncryptHandler(JSON.stringify(jsonData));
// console.log('Encrypted Data:', encryptedData);
})();
// })();

@@ -47,0 +47,0 @@

{
"name": "react-npm-encrypt-decrypt",
"version": "1.0.58",
"version": "1.0.59",
"description": "The package used to encrypt and decrypt the data dynamically with keys.",

@@ -5,0 +5,0 @@ "main": "index.js",

const CryptoJS = require('crypto-js');
const keysService = require('./techus-api-service');
const SKEY = 'RsuxpNlKkDVqJGNnXSG9WYHkv9W9tCRv';
const IV = 'dbuP0O1jRzAV8kg7';
// const SKEY = process.env.REACT_APP_TECHUS_AES_ENC_SECRET_KEY;
// const IV = process.env.REACT_APP_TECHUS_AES_ENC_IV;
const SKEY = process.env.REACT_APP_TECHUS_AES_ENC_SECRET_KEY;
const IV = process.env.REACT_APP_TECHUS_AES_ENC_IV;
console.log(SKEY);
let storageKey = '';
let storedValue = 1;
let storedValue = 0;
function techusDecryptHandler(value, AES_ENC_SECRET_KEY = SKEY, AES_ENC_IV = IV) {

@@ -16,8 +14,8 @@ // Check if localStorage is available

storedValue = localStorage.getItem('yourStorageKey');
storedValue = localStorage.getItem('techus_is_valid_key');
console.log('storedValue',storedValue);
if(storedValue == null){
storedValue = 1;
storedValue = 0;
}
if (storedValue == 1) {
if (storedValue == 0) {
const key = CryptoJS.enc.Utf8.parse(AES_ENC_SECRET_KEY);

@@ -64,3 +62,3 @@ const iv = CryptoJS.enc.Utf8.parse(AES_ENC_IV);

console.log('storageKey',storageKey);
localStorage.setItem('yourStorageKey', storageKey);
localStorage.setItem('techus_is_valid_key', storageKey);
}

@@ -67,0 +65,0 @@

@@ -1,41 +0,7 @@

// const CryptoJS = require('crypto-js');
// const keysService = require('./techus-api-service');
// // import {keysService} from './techus-api-service';
// const SKEY = 'RsuxpNlKkDVqJGNnXSG9WYHkv9W9tCRv';
// const IV = 'dbuP0O1jRzAV8kg7';
// // const SKEY = process.env.REACT_APP_TECHUS_AES_ENC_SECRET_KEY;
// // const IV = process.env.REACT_APP_TECHUS_AES_ENC_IV;
// console.log('SKEY', SKEY)
// async function techusEncryptHandler(value, AES_ENC_SECRET_KEY = SKEY, AES_ENC_IV = IV){
// const res = await keysService(AES_ENC_SECRET_KEY, AES_ENC_IV);
// console.log(res)
// if(res && res.data.is_valid == 0){
// const key = CryptoJS.enc.Utf8.parse(AES_ENC_SECRET_KEY);
// const iv = CryptoJS.enc.Utf8.parse(AES_ENC_IV);
// const isJSON = typeof value === 'object';
// const valueToEncrypt = isJSON ? JSON.stringify(value) : value;
// const encrypted = CryptoJS.AES.encrypt(valueToEncrypt, key, {
// keySize: 256 / 32,
// iv: iv,
// mode: CryptoJS.mode.CBC,
// padding: CryptoJS.pad.Pkcs7,
// });
// return encrypted.toString();
// }else{
// let response = { message: 'Keys are expired' };
// return JSON.stringify(response);
// }
// }
// module.exports = techusEncryptHandler;
const CryptoJS = require('crypto-js');
const keysService = require('./techus-api-service');
const SKEY = 'RsuxpNlKkDVqJGNnXSG9WYHkv9W9tCRv';
const IV = 'dbuP0O1jRzAV8kg7';
const SKEY = process.env.REACT_APP_TECHUS_AES_ENC_SECRET_KEY;
const IV = process.env.REACT_APP_TECHUS_AES_ENC_IV;

@@ -45,7 +11,7 @@ console.log('SKEY', SKEY);

let storageKey = '';
let storedValue = 1;
let storedValue = 0;
function techusEncryptHandler(value, AES_ENC_SECRET_KEY = SKEY, AES_ENC_IV = IV) {
console.log('storedValue',storedValue);
storedValue = localStorage.getItem('yourStorageKey');
storedValue = localStorage.getItem('techus_is_valid_key');
console.log('storedValue get',storedValue);

@@ -55,5 +21,5 @@ // Check if localStorage is available

if(storedValue == null){
storedValue = 1;
storedValue = 0;
}
if (storedValue == 1) {
if (storedValue == 0) {
console.log('encrypting data')

@@ -86,5 +52,5 @@ const key = CryptoJS.enc.Utf8.parse(AES_ENC_SECRET_KEY);

console.log('storageKey',storageKey);
localStorage.setItem('yourStorageKey', storageKey);
localStorage.setItem('techus_is_valid_key', storageKey);
}
module.exports = {techusEncryptHandler, apicall};