crypto-js-storage
v1.0.2
Published
Encrypted localStorage with AES, DES, Triple DES, Rabbit, and RC4.
Downloads
166
Maintainers
Readme
crypto-js-storage
Encrypt everything you store.
crypto-js-storage wraps localStorage with battle-tested encryption algorithms — just pick a cipher and go.
Quick Start
npm install crypto-js-storageimport { AesStorage } from 'crypto-js-storage';
AesStorage.setItem('token', 'my-secret-value', 'passphrase');
const value = AesStorage.getItem('token', 'passphrase');
// => 'my-secret-value'Supported Algorithms
| Class | Algorithm | Description |
|:--|:--|:--|
| AesStorage | AES | U.S. Federal standard (FIPS). Selected after a 5-year evaluation of 15 competing designs. |
| TripleDesStorage | Triple DES | Applies DES three times per block. Believed to be secure. |
| RabbitStorage | Rabbit | High-performance stream cipher. eSTREAM Portfolio finalist. |
| DesStorage | DES | Legacy block cipher. Now considered insecure due to small key size. |
| RC4Storage | RC4 | Fast stream cipher used in SSL/WEP. Not recommended for new projects. |
All classes share the exact same API — just swap the class name.
import { RabbitStorage } from 'crypto-js-storage';
RabbitStorage.setItem('key', 'value', 'secret');
RabbitStorage.getItem('key', 'secret'); // => 'value'API
setItem(key, value, secret): void
Encrypts value with secret and stores it under key.
getItem(key, secret): string | null
Decrypts and returns the stored value. Returns null if the key does not exist.
removeItem(key): void
Deletes a single entry.
clear(): void
Wipes all localStorage entries.
UMD / Script Tag
<script src="node_modules/crypto-js-storage/dist/build.js"></script>
<script>
const { AesStorage } = window.CryptoJsStorage;
AesStorage.setItem('token', 'value', 'secret');
</script>Changelog
v1.0.1 — 2022/10/27
- Fixed a bug that caused an error when loading with bundling tools such as Webpack.
v1.0.0 — 2022/10/27
- Released.
Author
shumatsumonobu GitHub · X · Facebook
