New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-native-aes-256

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-aes-256

This React Native library provides a secure and convenient way to encrypt and decrypt data using the industry-standard AES-256 algorithm. It seamlessly integrates with your React Native application, allowing you to protect sensitive information on both An

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

react-native-aes-256 Library

This React Native library provides a secure and convenient way to encrypt and decrypt data using the industry-standard AES-256 algorithm. It seamlessly integrates with your React Native application, allowing you to protect sensitive information on both Android and iOS platforms.

Key Features:

  • Robust AES-256 Encryption: Leverages the highly secure AES-256 encryption algorithm for reliable data protection.
  • Native Module Integration: Utilizes a native module for enhanced performance and platform-specific security features.
  • Simplified API: Offers a user-friendly API with functions for encryption, decryption, and secure key/IV generation.
  • Error Handling: Includes error checking for invalid key and IV lengths, preventing potential issues.

Installation

  1. Dependency Installation: Install the library using npm or Yarn:

    npm install react-native-aes-256
    
    yarn add react-native-aes-256
    
  2. Platform-Specific Linking:

    • iOS: Run pod install in your iOS project directory.
    • Android: Rebuild your app after installing the package.

Usage

  1. Import the functions:

    import { encrypt, decrypt, generateSecureKey, generateSecureIV } from 'react-native-aes-256';
    
  2. Encryption:

    // Optional you can use any 32 character string
    const secureKey = await generateSecureKey('your_password'); 
    
    // Optional you can use any 16 character string
    const iv = await generateSecureIV('another_password'); 
    
    const encryptedData = await encrypt(secureKey, iv, 'your_data_to_encrypt');
    
  3. Decryption:

    const decryptedData = await decrypt(secureKey, iv, encryptedData);
    

API Reference

  • encrypt(secureKey: string, iv: string, toBeEncrypted: string): Promise<string>: Encrypts a string using the provided key and IV.
  • decrypt(secureKey: string, iv: string, toBeDecrypted: string): Promise<string>: Decrypts a string using the provided key and IV.
  • generateSecureKey(password: string): Promise<string>: Generates a secure key from a password.
  • generateSecureIV(password: string): Promise<string>: Generates a secure initialization vector (IV) from a password.

Error Handling

  • The encrypt and decrypt functions reject promises with informative error messages if the key or IV lengths are invalid.
  • The IV length should be 16
  • The SecrueKey length should be 32

Security Considerations

  • Always store keys and IVs securely. Avoid hardcoding them in your code.

Example

A basic example of encrypting and decrypting data can be found in the example folder.

License

This library is licensed under the (MIT License).

Keywords

FAQs

Package last updated on 12 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc