react-native-x25519-keys
v1.0.6
Published
Cross-platform x25519 key pair generation for React Native
Readme
react-native-x25519-keys
- This module creates a base64 encoded Curve25519 key pair.
- It uses the curve25519-donna library underneath.
- For RNG
SecureRandomandSecRandomCopyBytesare used for Android and iOS, respectively.
Getting started
$ npm install react-native-x25519-keys --save
Mostly automatic installation
$ react-native link react-native-x25519-keys
Manual installation
iOS
- In XCode, in the project navigator, right click
Libraries➜Add Files to [your project's name] - Go to
node_modules➜react-native-x25519-keysand addRNX25519Keys.xcodeproj - In XCode, in the project navigator, select your project. Add
libRNX25519Keys.ato your project'sBuild Phases➜Link Binary With Libraries - In XCode, in the project navigator, select your project. Add
$(SRCROOT)/../node_modules/react-native-x25519-keys/iosto your project'sBuild Settings➜Header Search Paths - Run your project (
Cmd+R)<
Android
- Open up
android/app/src/main/java/[...]/MainActivity.java- Add
import com.wirevpn.x25519keys.RNX25519KeysPackage;to the imports at the top of the file - Add
new RNX25519KeysPackage()to the list returned by thegetPackages()method
- Add
- Append the following lines to
android/settings.gradle:include ':react-native-x25519-keys' project(':react-native-x25519-keys').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-x25519-keys/android') - Insert the following lines inside the
dependenciesblock inandroid/app/build.gradle:compile project(':react-native-x25519-keys')
Usage
import RNX25519Keys from 'react-native-x25519-keys';
RNX25519Keys.GenKeyPair().then(keys => {
console.log(keys.public_key);
console.log(keys.private_key);
});