A wrapper for native browser Storage (localStorage/sessionStorage) that encrypts data using crypto-js. Current stable version is 2.14.7, released frequently (multiple minor versions per month). It automatically encrypts and decrypts values, supports multiple storage instances, and allows configuration of encryption algorithm, prefix, and state management hooks. Unlike simple base64 encoding libraries, encrypt-storage uses AES encryption with a user-provided secret key, making it harder for casual users to read data from the console. However, as noted in the docs, nothing on the frontend is truly secure as the key is exposed. Ships TypeScript types. This is the v2 line with breaking changes from v1.
npm install encrypt-storageNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to initialize EncryptStorage with a secret key and options, then set/get/remove single and multiple items.
Refer to migration guide in docs. Update options object keys and method calls to v2 API.
Use encAlgorithm: 'AES' instead of 'TripleDES'.
Understand that this provides obfuscation, not real security. Do not store truly sensitive data.
Set stateManagementUse to false if you manage state manually, or batch updates.
Ensure doNotEncryptValues does not contain any sensitive data patterns.
Ensure you pass a non-empty string as the first argument: `new EncryptStorage('my-secret-key')`Use an alternative storage or wrap in a check for `typeof window !== 'undefined'`.
Use EncryptStorage methods consistently, or catch and parse the raw value.