Skip to content

React Native OpenPGP for iOS and Android (in development)

License

Notifications You must be signed in to change notification settings

quan-to/react-native-pgp

Repository files navigation

react-native-pgp

React Native OpenPGP for iOS and Android (in development)

Documentation

Install

npm --save install react-native-pgp
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

import { NativeModules } from 'react-native';
const RNPGP = NativeModules.ReactNativePGP;

Example

Generating Key-Pair

const userName = 'myUsername';
const keyBits = 4096;
const keyPassword = 'mySuperSecretPassword';

const keyPair = await RNPGP.generateKeyPair(userName, keyBits, keyPassword);
// Returns an object with privateKey and publicKey in ASCII Armored Format
console.log(keyPair.privateKey);
console.log(keyPair.publicKey);

Signing data

const privateKey = `
-----BEGIN PGP PRIVATE KEY BLOCK-----
...
-----END PGP PRIVATE KEY BLOCK-----`;

const privateKeyPassword = 'mySuperSecretPassword';
const dataToSign = 'I signed this, no one else!';

const signed = await RNPGP.signData(privateKey, privateKeyPassword, dataToSign);
// Returns an object with asciiArmoredSignature, fingerPrint and hashingAlgo

console.log(signed.asciiArmoredSignature); // "-----BEGIN PGP SIGNATURE----- ... -----END PGP SIGNATURE-----"

Methods

  • generateKeyPair(userName, keyBits, keyPassword) - Generates a public/private keyPair and encrypts the private key with specified password.
  • signData(asciiArmoredPrivateKey, privateKeyPassword, dataToSign) - Signs the data using the private key
  • setHashingAlgo(hashingAlgo) - Sets the hashing algorithm (check the Constants)

Errors

TODO

Contributing

If you want to contribute, see the Contributing guidelines before and feel free to send your contributions.

About

React Native OpenPGP for iOS and Android (in development)

Resources

License

Stars

Watchers

Forks

Packages

No packages published