@jihyunlab/web-secure-storage
v2.1.6
Published
JihyunLab Web secure storage.
Downloads
225
Readme
@jihyunlab/web-secure-storage
@jihyunlab/web-secure-storage can be used by web applications.
@jihyunlab/web-secure-storage encrypts values and stores them in local or session storage. When retrieving stored values, they are decrypted back to their original values
The encryption function is implemented with @jihyunlab/web-crypto and provides encryption for AES 256 CBC and AES 256 GCM.
Installation
npm i @jihyunlab/web-secure-storage
Usage
You can easily encrypt data and store it in storage, then retrieve it.
import {
CIPHER,
STORAGE,
WebSecureStorage,
} from '@jihyunlab/web-secure-storage';
const storage = await WebSecureStorage.create(
STORAGE.LOCAL,
CIPHER.AES_256_GCM,
'your secret key'
);
storage.clear();
await storage.setItem('item', 'jihyunlab'); // 89b1e3c2996e08d5549ecb9d625faca6db785c7d0f9ba51c3985e80ae1143263273308f5eb
const value = await storage.getItem('item');
console.log(value); // jihyunlab
storage.removeItem('item');
You can configure encryption options such as salt and iteration.
const storage = await WebSecureStorage.create(
STORAGE.LOCAL,
CIPHER.AES_256_GCM,
'your secret key',
{
salt: 'salt',
iterations: 256,
}
);
Credits
Authored and maintained by JihyunLab <[email protected]>
License
Open source licensed as MIT.