Ravi Vishwakarma is a dedicated Software Developer with a passion for crafting efficient and innovative solutions. With a keen eye for detail and years of experience, he excels in developing robust software systems that meet client needs. His expertise spans across multiple programming languages and technologies, making him a valuable asset in any software development project.
ICSM Computer
13-Jul-2025Yes, IndexedDB can store encrypted data, but it does not offer encryption by default. To protect sensitive data—such as personal information, tokens, or health records—you must manually encrypt the data before storing it and decrypt it when retrieving.
Why Encrypt IndexedDB?
How to Encrypt IndexedDB Data
Here’s a step-by-step guide using the Web Crypto API, which is built into all modern browsers.
1. Generate or Import a Crypto Key
Use a symmetric key (e.g., AES-GCM) for encrypting and decrypting.
Or import an existing key:
2. Encrypt Data Before Storing
Then store this encrypted payload in IndexedDB.
3. Decrypt When Reading
4. Save and Load in IndexedDB
Here’s a basic example of saving an encrypted object:
And reading/decrypting it later:
When to Encrypt
Encrypt in IndexedDB when you:
Summary