react-native-pgp
React Native OpenPGP for iOS and Android (in development)
Documentation
Install
npm --save install react-native-pgpreact-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
;const RNPGP = NativeModulesReactNativePGP;
Example
Generating Key-Pair
const userName = 'myUsername';const keyBits = 4096;const keyPassword = 'mySuperSecretPassword'; const keyPair = await RNPGP;// Returns an object with privateKey and publicKey in ASCII Armored Formatconsole;console;
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;// Returns an object with asciiArmoredSignature, fingerPrint and hashingAlgo console; // "-----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 keysetHashingAlgo(hashingAlgo)
- Sets the hashing algorithm (check the Constants)
Erros
TODO
Contributing
If you want to contribute, see the Contributing guidelines before and feel free to send your contributions.