From 6d548dff8d5b774be3953d6c0ac7cfc428ca87c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandru=20Vl=C4=83du=C5=A3u?= Date: Wed, 25 Jun 2014 14:30:32 +0300 Subject: [PATCH] Update README.md to add decryption example Update README.md to add decryption example --- README.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 07b3c587..99da8114 100644 --- a/README.md +++ b/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`.