encrypt-webstorage code example

Example 1: encrypt-webstorage

npm install encrypt-webstorage@latest

Example 2: encrypt-webstorage

import {EncryptionService} from "encrypt-webstorage";

constructor(private encryptor : EncryptionService){}

const secret_key = "!!34fffd99kdsdnn@as"

// encrypt decryption value without secret key

   let encryptedString = this.encryptor.encryptionAES({"test" : "test"});

    console.log('encrypted',encryptedString); //encrypted U2FsdGVkX19qgGyDwcinGl24YVn1e7fmcdR3t/v43BA=

    let decryptedValue = this.encryptor.decryptionAES(encryptedString);

    console.log('decrypted',decryptedValue); //decrypted {test: "test"}

// encrypt decryption value without secret key

 this.encryptor.encryptionAES({"test" : "test"}, secret_key);

 this.encryptor.decryptionAES(encryptedString, secret_key);


// can able to pass all the types code will handle stringify and parse

Example 3: encrypt-webstorage

import {WebStorageService} from "encrypt-webstorage";

constructor(private webStorage : WebStorageService){}

// setting the value in session storage
this.webStorage.setItem('test','test'); // U2FsdGVkX1+cLZpklSZLV2mptR9S/px4TtOMBjIeOUU=
this.webStorage.setItem('test',10);
this.webStorage.setItem('test',{"test" : "test"});
// can able to pass all the types code will handle stringify and parse

// get the value back from session
this.webStorage.setItem('test'); //test

Example 4: encrypt-webstorage

npm install --legacy-peer-deps --save encrypt-webstorage@latest

Tags:

Php Example