npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@rrishuyadav/react-native-encrypted-async-storage

v1.0.2

Published

A encryption library for ReactJS and React Native Web

Readme

📦 React Native Encrypted Async Storage

Secure Storage Middleware for React Native Applications


🚀 Introduction

React Native Encrypted Async Storage is a secure storage library that acts as a middleware, combining the strengths of:

  • rn-encryption: Provides encryption capabilities for secure data handling.
  • react-native-async-storage: A robust, community-driven storage solution for React Native applications.

This library ensures all your storage operations, such as setting, getting, and merging data, are encrypted securely using industry-standard AES-GCM encryption.


🛠️ Installation

npm i @rrishuyadav/react-native-encrypted-async-storage
# or
yarn add @rrishuyadav/react-native-encrypted-async-storage

Ensure rn-encryption and react-native-async-storage are also installed as dependencies.

npm install rn-encryption @react-native-async-storage/async-storage

📝 Key Features

  • 🔒 AES-GCM Encryption: Ensures your data is encrypted and secure at rest.
  • Async Operations: Fully supports asynchronous operations for all storage methods.
  • 🗝️ Key Management: Seamless encryption key management.
  • 🧩 Data Merge: Merge complex JSON objects while maintaining encryption.
  • 📊 Batch Operations: Efficient batch operations like multiSet, multiGet, and multiRemove.

📚 API Reference

1. setItem & getItem

Store and Retrieve Encrypted Data

await EncryptedAsyncStorage.setItem('testKey', 'Hello, Encrypted World!');
const value = await EncryptedAsyncStorage.getItem('testKey');
console.log('Decrypted Value:', value); // Output: Hello, Encrypted World!

2. removeItem

Remove an Item from Storage

await EncryptedAsyncStorage.removeItem('testKey');
const value = await EncryptedAsyncStorage.getItem('testKey');
console.log('Value after removeItem:', value); // Output: null

3. multiSet & multiGet

Store and Retrieve Multiple Encrypted Items

await EncryptedAsyncStorage.multiSet([
  ['key1', 'value1'],
  ['key2', 'value2'],
]);

const values = await EncryptedAsyncStorage.multiGet(['key1', 'key2']);
console.log('MultiGet Values:', values);
// Output: [['key1', 'value1'], ['key2', 'value2']]

4. getAllKeys

Retrieve All Keys from Storage

const keys = await EncryptedAsyncStorage.getAllKeys();
console.log('All Keys:', keys);
// Output: ['key1', 'key2']

5. multiRemove

Remove Multiple Items

await EncryptedAsyncStorage.multiRemove(['key1', 'key2']);
const keysAfterRemove = await EncryptedAsyncStorage.getAllKeys();
console.log('Keys after multiRemove:', keysAfterRemove);
// Output: []

6. mergeItem

Merge JSON Data for a Single Item

await EncryptedAsyncStorage.setItem('mergeKey', JSON.stringify({ name: 'John' }));
await EncryptedAsyncStorage.mergeItem('mergeKey', JSON.stringify({ age: 30 }));

const mergedValue = await EncryptedAsyncStorage.getItem('mergeKey');
console.log('Merged Value:', mergedValue);
// Output: {"name": "John", "age": 30}

7. multiMerge

Merge JSON Data for Multiple Items

await EncryptedAsyncStorage.multiSet([
  ['user1', JSON.stringify({ name: 'Alice' })],
  ['user2', JSON.stringify({ name: 'Bob' })],
]);

await EncryptedAsyncStorage.multiMerge([
  ['user1', JSON.stringify({ age: 25 })],
  ['user2', JSON.stringify({ age: 28 })],
]);

const mergedUsers = await EncryptedAsyncStorage.multiGet(['user1', 'user2']);
console.log('MultiMerged Users:', mergedUsers);
// Output: [['user1', '{"name": "Alice", "age": 25}'], ['user2', '{"name": "Bob", "age": 28}']]

📊 Example Usage

🔑 Initialization & Testing

import EncryptedAsyncStorage from 'react-native-encrypted-asyncstorage';

useEffect(() => {
  const init = async () => {
    try {
      console.log('--- Testing EncryptedAsyncStorage ---');

      // Set and Get Item
      await EncryptedAsyncStorage.setItem('testKey', 'Hello, Encrypted World!');
      const value = await EncryptedAsyncStorage.getItem('testKey');
      console.log('Decrypted Value:', value);

      // Remove Item
      await EncryptedAsyncStorage.removeItem('testKey');

      // MultiSet & MultiGet
      await EncryptedAsyncStorage.multiSet([
        ['key1', 'value1'],
        ['key2', 'value2'],
      ]);
      const multiValues = await EncryptedAsyncStorage.multiGet(['key1', 'key2']);
      console.log('MultiGet Values:', multiValues);

      // Merge Items
      await EncryptedAsyncStorage.setItem('mergeKey', JSON.stringify({ name: 'John' }));
      await EncryptedAsyncStorage.mergeItem('mergeKey', JSON.stringify({ age: 30 }));
      const mergedValue = await EncryptedAsyncStorage.getItem('mergeKey');
      console.log('Merged Value:', mergedValue);

      console.log('--- EncryptedAsyncStorage Test Completed Successfully ---');
    } catch (error) {
      console.error('Error in EncryptedAsyncStorage:', error);
    }
  };

  init();
}, []);

🛡️ Security Features

  1. AES-GCM Encryption: Industry-standard AES encryption ensures data confidentiality and integrity.
  2. Key Management: Keys are securely stored and retrieved.
  3. Data Integrity: Prevents tampering by verifying encrypted payloads.

📦 Configuration

No additional configuration is required. Install the library and start using the API.


📚 Best Practices

  • Always validate inputs before encrypting and storing them.
  • Avoid storing highly sensitive data in Async Storage; use native keychain solutions for secrets.

🐛 Troubleshooting

  • Issue: Data not decrypting correctly.
    Solution: Ensure encryption keys are not rotated or lost.

  • Issue: Merging fails after encryption.
    Solution: Always fetch, decrypt, and merge JSON objects before re-encrypting.


🤝 Contributing

  1. Fork the repository.
  2. Create a feature branch: git checkout -b feature/your-feature.
  3. Commit changes: git commit -m "Add your feature".
  4. Push to the branch: git push origin feature/your-feature.
  5. Open a pull request.

📄 License

MIT License. See the LICENSE file for details.


📣 Connect with Me – Let's Build Something Great Together! 🚀

Hey there! 👋 I'm Rishabh, the creator of React Native Encrypted Async Storage – a library designed to make secure storage seamless and reliable in React Native applications.

I'm passionate about building innovative mobile and web solutions, mentoring teams, and solving real-world problems with clean and efficient code.

🤝 Let's Collaborate!

Please do not hesitate to contact me in case some modification or additional functionality required from the library.

Looking forward to hearing from you! 🚀✨