AES-GCM encryption/decryption for React Native

Overview

react-native-aes-gcm-crypto

AES-GCM encryption/decryption for React Native

Requirements

  • iOS >= 13.0
  • Android >= 26

Installation

npm install react-native-aes-gcm-crypto

Usage

import AesGcmCrypto from 'react-native-aes-gcm-crypto';

const key = 'Yzg1MDhmNDYzZjRlMWExOGJkNTk5MmVmNzFkOGQyNzk=';

AesGcmCrypto.decrypt(
  'LzpSalRKfL47H5rUhqvA',
  key,
  '131348c0987c7eece60fc0bc',
  '5baa85ff3e7eda3204744ec74b71d523',
  false
).then((decryptedData) => {
  console.log(decryptedData);
});

AesGcmCrypto.encrypt('{"name":"Hoge"}', false, key).then((result) => {
  console.log(result);
});

Encrypt data

type EncryptedData = {
  iv: string;
  tag: string;
  content: string;
};

function encrypt(
  plainText: string,
  inBinary: boolean,
  key: string
): Promise<EncryptedData>;
  • plainText: A string data to encrypt. If inBinary is true, it should be encoded in Base64.
  • inBinary: true to encrypt binary data encoded with Base64
  • key: AES key in Base64

Encrypt file

function encryptFile(
  inputFilePath: string,
  outputFilePath: string,
  key: string
): Promise<{
  iv: string;
  tag: string;
}>;
  • inputFilePath: A file path to encrypt
  • outputFilePath: An output file path
  • key: AES key in Base64

Decrypt data

function decrypt(
  base64Ciphertext: string,
  key: string,
  iv: string,
  tag: string,
  isBinary: boolean
): Promise<string>;
  • base64Ciphertext: A base64 data to decrypt.
  • key: AES key in Base64
  • iv: An initialization vector
  • tag: An auth tag
  • isBinary: true to return decrypted data in Base64

Decrypt file

function decrypt(
  inputFilePath: string,
  outputFilePath: string,
  key: string,
  iv: string,
  tag: string
): Promise<boolean>;
  • inputFilePath: A file path to decrypt
  • outputFilePath: An output file path
  • key: AES key in Base64
  • iv: An initialization vector
  • tag: An auth tag
  • isBinary: true to return decrypted data in Base64

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

Author

Takuya Matsuyama | @inkdrop_app

Made for my app called Inkdrop - A Markdown note-taking app

License

MIT

You might also like...

A command-line tool to securely encrypt passwords and notes using AES encryption.

Treasury A command-line tool to securely encrypt passwords and notes using AES encryption. Installation Usage Technology Built solely in Java Picocli

Oct 17, 2022

Encryption/Decryption - University Project

Encryption/Decryption - University Project

J-Crypt By JayMar921 Encryption/Decryption - University Project J-Crypt is a Java Program that encrypt/decrypts a String. You can use your own key for

Nov 4, 2021

Sceneform React Native AR Component using ARCore and Google Filament as 3D engine. This the Sceneform Maintained Component for React Native

Sceneform React Native AR Component using ARCore and Google Filament as 3D engine. This the Sceneform Maintained Component for React Native

Discord Server Join us on Discord if you need a hand or just want to talk about Sceneform and AR. Features Remote and local assets Augmented Faces Clo

Dec 17, 2022

With react-native-update-in-app library you can easily implement in-app updates in your React Native app using CDN or any other file server

React Native In-App update With react-native-update-in-app library you can easily implement in-app updates in your React Native app using CDN or any o

Dec 21, 2022

AES block cipher modes with user interface.

AES block cipher modes with user interface.

AES Ciphers An implementation of The common AES block cipher modes of operations (ECB, CBC, CTR), with user interface. It allows you to encrypt and de

Nov 21, 2022

Spring Native provides beta support for compiling Spring applications to native executables using GraalVM native-image compiler.

Spring Native provides beta support for compiling Spring applications to native executables using GraalVM native-image compiler.

Spring Native provides beta support for compiling Spring applications to native executables using GraalVM native-image compiler.

Jan 6, 2023

React native wrapper for Jitsi Meet SDK Library that rely on the native view (Activity / ViewController)

react-native-jitsi-meet-sdk React native wrapper for Jitsi Meet SDK Library. This Library implements the Jitsi SDK with a native activity on the Andro

May 2, 2022

An awesome native wheel picker component for React Native.

An awesome native wheel picker component for React Native.

⛏️ react-native-picky An awesome native wheel picker component for react-native. Features Supports multiple columns ✅ Supports looping ✅ Native Androi

Dec 4, 2022

KakaoSDK Bridge for React, React-Native, RNW

KakaoSDK Bridge for React, React-Native, RNW

KakaoSDK for React, React-Native Use Dependencies iOS Android Web 2.5.0 2.5.0 1.39.14 처음 설치 시 주의 사항 (React-Native 만) 해당 모듈은 Swift로 되어있어서 그냥 가동 시 작동이 안

May 2, 2022

The react-native Baidu voice library provides voice recognition, voice wake-up and voice synthesis interfaces. react-native百度语音库,提供语音识别,语音唤醒以及语音合成接口。

The react-native Baidu voice library provides voice recognition, voice wake-up and voice synthesis interfaces. react-native百度语音库,提供语音识别,语音唤醒以及语音合成接口。

react-native-baidu-asr react-native-baidu-asr It is a Baidu speech library under React Native, which can perform speech recognition, speech wake-up an

Oct 12, 2022

BitTorrent library and client with DHT, magnet links, encryption and more

BitTorrent library and client with DHT, magnet links, encryption and more

Bt A full-featured BitTorrent implementation in Java 8 peer exchange | magnet links | DHT | encryption | LSD | private trackers | extended protocol |

Jan 2, 2023

Multi-platform transparent client-side encryption of your files in the cloud

Multi-platform transparent client-side encryption of your files in the cloud

Supporting Cryptomator Cryptomator is provided free of charge as an open-source project despite the high development effort and is therefore dependent

Jan 5, 2023

JSON Web Token (JWT) implementation for Java with support for signatures (JWS), encryption (JWE) and web keys (JWK).

Nimbus JOSE+JWT Nimbus JOSE+JWT is a popular open source (Apache 2.0) Java library which implements the Javascript Object Signing and Encryption (JOSE

Jul 1, 2022

Plugin-power - A plugin for the ja-netfilter, it is a dragon slayer for asymmetric encryption.

plugin-power A plugin for the ja-netfilter, it is a dragon slayer for asymmetric encryption. Use the mvn clean package command to compile and use powe

May 25, 2022

Java Project based on Java and Encryption using Cryptography algorithms

Symmetric-Encryption-Cryptography-in-Java Java Project based on Java and Encryption using Cryptography algorithms Project Aim Develop Java program to

Feb 3, 2022

Simple and extensible storage service implementation with optional encryption.

Simple and extensible storage service implementation with optional encryption.

Simple and extensible storage service implementation with optional encryption. About Hole Hole is a simple data storage made with a soul for those who

Aug 13, 2022

MixStack lets you connects Flutter smoothly with Native pages, supports things like Multiple Tab Embeded Flutter View, Dynamic tab changing, and more. You can enjoy a smooth transition from legacy native code to Flutter with it.

MixStack lets you connects Flutter smoothly with Native pages, supports things like Multiple Tab Embeded Flutter View, Dynamic tab changing, and more. You can enjoy a smooth transition from legacy native code to Flutter with it.

中文 README MixStack MixStack lets you connects Flutter smoothly with Native pages, supports things like Multiple Tab Embeded Flutter View, Dynamic tab

Dec 19, 2022

A React Native project starter with Typescript, a theme provider with hook to easy styling component, a folder architecture ready and some configs to keep a codebase clean.

React Native Boilerplate Folder structure : src ├── assets │   ├── audios │   ├── fonts │   ├── icons │   └── images ├── components │   ├── Layout.tsx

Sep 1, 2022

Lightweight React Native UI Components inspired on Vant

vant-react-native Install yarn add vant-react-native Or npm install vant-react-native Usage import React, { Component } from 'react'; import { View, T

Sep 29, 2022
Comments
  • Why does the Android SDK need to be at least 26?

    Why does the Android SDK need to be at least 26?

    Thank you for providing this great library!

    I have a question. Why does the Android SDK need to be at least 26 to use this? That means we cannot support android 7 and below. If you have a reason, could you please tell me?

    opened by gaishimo 5
  • [TypeError: null is not an object (evaluating '_reactNativeAesGcmCrypto.default.decrypt')]

    [TypeError: null is not an object (evaluating '_reactNativeAesGcmCrypto.default.decrypt')]

    i got this error when run line:

    const key = rsaKeyRef.current
                const iv = rsaKeyRef.current.slice(0, 16)
                const decrypt = AesGcmCrypto.decrypt(data, key, iv, '', true)
                .then(result => {
                    console.log('decrypt result', result)
                }).catch(error => {
                    console.log('decrypt error', error)
                })
                
    

    the pod is install success Installing react-native-aes-gcm-crypto (0.2.1) can u help?

    opened by fukemy 1
  • Not able to Install pod

    Not able to Install pod

    I m getting following error when trying to install pod, although dependencies already been addded. [!] The following Swift pods cannot yet be integrated as static libraries:

    The Swift pod react-native-aes-gcm-crypto depends upon React-Core, which does not define modules. To opt into those targets generating module maps (which is necessary to import them from Swift when building as static libraries), you may set use_modular_headers! globally in your Podfile, or specify :modular_headers => true for particular dependencies.

    opened by pverma1 1
Releases(v0.2.0)
Owner
Takuya Matsuyama
Digital craftsman ╥━━━━━━━━╭━━╮━━┳ ╢╭╮╭━━━━━┫┃▋▋━▅┣ ╢┃╰┫┈┈┈┈┈┃┃┈┈╰┫┣ ╢╰━┫┈┈┈┈┈╰╯╰┳━╯┣ ╢┊┊┃┏┳┳━━┓┏┳┫┊┊┣ ╨━━┗┛┗┛━━┗┛┗┛━━┻
Takuya Matsuyama
Encryption/Decryption - University Project

J-Crypt By JayMar921 Encryption/Decryption - University Project J-Crypt is a Java Program that encrypt/decrypts a String. You can use your own key for

JayMar 2 Nov 4, 2021
AES block cipher modes with user interface.

AES Ciphers An implementation of The common AES block cipher modes of operations (ECB, CBC, CTR), with user interface. It allows you to encrypt and de

Abd El-Twab M. Fakhry 6 Nov 21, 2022
The react-native Baidu voice library provides voice recognition, voice wake-up and voice synthesis interfaces. react-native百度语音库,提供语音识别,语音唤醒以及语音合成接口。

react-native-baidu-asr react-native-baidu-asr It is a Baidu speech library under React Native, which can perform speech recognition, speech wake-up an

dengweibin 11 Oct 12, 2022
Multi-platform transparent client-side encryption of your files in the cloud

Supporting Cryptomator Cryptomator is provided free of charge as an open-source project despite the high development effort and is therefore dependent

Cryptomator 8.7k Jan 5, 2023
JSON Web Token (JWT) implementation for Java with support for signatures (JWS), encryption (JWE) and web keys (JWK).

Nimbus JOSE+JWT Nimbus JOSE+JWT is a popular open source (Apache 2.0) Java library which implements the Javascript Object Signing and Encryption (JOSE

Connect2ID 35 Jul 1, 2022
Java Project based on Java and Encryption using Cryptography algorithms

Symmetric-Encryption-Cryptography-in-Java Java Project based on Java and Encryption using Cryptography algorithms Project Aim Develop Java program to

Muhammad Asad 6 Feb 3, 2022
Spring-react-security - 🌶 Spring Security & React 🌶

Spring-react-security - ?? Spring Security & React ??

KimJunhan 2 Mar 28, 2022
Engin Demiroğun düzenlemiş olduğu (Java & React) Yazılım Geliştirici Yetiştirme Kampında yapmış olduğum ödevleri içermektedir.

Java-React-Yazilim-Gelistirici-Yetistirme-Kampi-Odevler Engin Demiroğun düzenlemiş olduğu (Java & React) Yazılım Geliştirici Yetiştirme Kampında yapmı

Baran Emre Türkmen 2 Apr 26, 2022
Kodlamaio Yazılım Geliştirici Yetiştirme Kampı (JAVA + REACT) ödev listesidir.

JavaHomeworks Kodlamaio Yazılım Geliştirici Yetiştirme Kampı (JAVA + REACT) ödev listesidir. JavaRecapDemo1 kodlama.io ileri java kampı 2. gün ödevidi

Rahim Cubuk 3 May 10, 2021
Kryptonite is a turn-key ready transformation (SMT) for Apache Kafka® Connect to do field-level 🔒 encryption/decryption 🔓 of records. It's an UNOFFICIAL community project.

Kryptonite - An SMT for Kafka Connect Kryptonite is a turn-key ready transformation (SMT) for Apache Kafka® to do field-level encryption/decryption of

Hans-Peter Grahsl 53 Jan 3, 2023