Update README.md

This commit is contained in:
Tankred Hase 2014-06-28 16:49:41 +02:00
parent f0e4128324
commit c3c8955571

View File

@ -11,24 +11,24 @@ For server side use, install via npm:
npm install openpgp
Examples:
### Examples
Encryption
#### 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:
#### 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);
privateKey.decrypt('passphrase');
var pgpMessage = '-----BEGIN PGP MESSAGE ... END PGP MESSAGE-----';
pgpMessage = openpgp.message.readArmored(pgpMessage);
var plaintext = openpgp.decryptMessage(privateKey, pgpMessage);
### Browser support