Update README.md to add decryption example
Update README.md to add decryption example
This commit is contained in:
parent
2dbe7e30b0
commit
6d548dff8d
14
README.md
14
README.md
|
@ -11,13 +11,25 @@ For server side use, install via npm:
|
|||
|
||||
npm install openpgp
|
||||
|
||||
Example:
|
||||
Examples:
|
||||
|
||||
Encryption
|
||||
|
||||
var openpgp = require('openpgp');
|
||||
var key = '-----BEGIN PGP PUBLIC KEY BLOCK ... END PGP PUBLIC KEY BLOCK-----';
|
||||
var publicKey = openpgp.key.readArmored(key);
|
||||
var pgpMessage = openpgp.encryptMessage(publicKey.keys, 'Hello, World!');
|
||||
|
||||
Decryption:
|
||||
|
||||
var openpgp = require('openpgp');
|
||||
var key = '-----BEGIN PGP PRIVATE KEY BLOCK ... END PGP PRIVATE KEY BLOCK-----';
|
||||
var privateKey = openpgp.key.readArmored(key).keys[0];
|
||||
privateKey.decrypt('password');
|
||||
var message = '-----BEGIN PGP MESSAGE ... END PGP MESSAGE-----';
|
||||
message = openpgp.message.readArmored(message);
|
||||
var pgpMessage = openpgp.decryptMessage(privateKey, message);
|
||||
|
||||
### Browser support
|
||||
|
||||
Fetch a minified build under [releases](https://github.com/openpgpjs/openpgpjs/releases). The library can be loaded via AMD/require.js or accessed globally via `window.openpgp`.
|
||||
|
|
Loading…
Reference in New Issue
Block a user