React-Native-OpenPGP
React-Native-OpenPGP is a Javascript implementation of the OpenPGP protocol based on OpenPGP.js.
Getting started
Installation
npm install --save react-native-openpgp
react-native link react-native-openpgp
Note: Run npm install -g rnpm
if you haven't installed RNPM (React-Native Package Manager) yet!
Alternatively you can add the Android and iOS modules library by following the official guide.
Usage
;
Encrypt and decrypt String data with a password
var options encrypted; options = data: 'Hello, World!' // input as String passwords: 'secret stuff' // multiple passwords possible; openpgp ;
options = message: openpgp // parse armored message password: 'secret stuff' // decrypt with password; openpgp ;
Encrypt and decrypt Uint8Array data with PGP keys
var options encrypted; var pubkey = '-----BEGIN PGP PUBLIC KEY BLOCK ... END PGP PUBLIC KEY BLOCK-----';var privkey = '-----BEGIN PGP PRIVATE KEY BLOCK ... END PGP PRIVATE KEY BLOCK-----'; options = data: 0x01 0x01 0x01 // input as Uint8Array publicKeys: openpgpkeys // for encryption privateKeys: openpgpkeys // for signing (optional) armor: false // don't ASCII armor; openpgp ;
options = message: openpgp // parse encrypted bytes publicKeys: openpgpkeys // for verification (optional) privateKey: openpgpkeys0 // for decryption format: 'binary' // output as Uint8Array; openpgp ;
Generate new key pair
var options = userIds: name:'Jon Smith' email:'jon@example.com' // multiple user IDs numBits: 2048 // RSA key size passphrase: 'super long and hard to guess secret' // protects the private key; openpgp ;