secured-storage
v1.0.6
Published
This is a secure way of storing key value in the browser based on localstorage and with military-grade encryption.
Downloads
43
Maintainers
Readme
What is secure storage and why should we use it?
Has it happened to you that you want to save sensitive data at the frontend level? Or you do not want information that we commonly store in localstorage or sessionstorage to be intercepted by the user or even by attackers, because due to these problems we have decided to create a plugin to allow secure storage in a very simple way, where you will no longer have to worry about encryption, keys, etc.
What is the operation?
To encrypt the information, AES of the CTR No Padding type is used, which is approved as part of the OWASP standards as a secure encryption algorithm, then it is saved to localStorage or sessionStorage depending on how you configure it in key/value format, for which the key is encrypted in MD5 and the value in AES CRT No Padding
How to install it?
npm (recommended)
$ npm i secured-storage --save
yarn
$ yarn add secured-storage
How is it used?
Initialization
We can initialize the library with the following code:
import { SecuredStorage } from 'secured-storage';
SecuredStorage.initalize({
key: "r')[4Zkj<X+~^-YH" // The password is optional, if you do not send it, it is automatically generated following the strictest standards
});
How to encrypt and save
To save securely you just have to call the "set" function, the first parameter is the key and the second parameter is the value, as shown in the following code example:
import { SecuredStorage } from 'secured-storage';
SecuredStorage.set("name", "Charlotte Smith");
How to decrypt and retrieve
To obtain a value and use the automatic decryption, just call the "get" function and it will return the value automatically
import { SecuredStorage } from 'secured-storage';
const name = SecuredStorage.get("name");
console.log(name); // Charlotte Smith
How delete
We can delete a record, specifying the value of its key
import { SecuredStorage } from 'secured-storage';
SecuredStorage.delete("name"); // This will permanently delete the name attribute
How to clear all storage
We can clean all the storage with a single command
import { SecuredStorage } from 'secured-storage';
SecuredStorage.clear(); // This will erase all storage permanently