readme: add syntax highlighting
This PR adds syntax highlighting to the readme. Thanks!
This commit is contained in:
parent
eedb722d7b
commit
5ca1801208
37
README.md
37
README.md
|
@ -33,30 +33,31 @@ OpenPGP.js uses ES6 promises which are available in [most modern browsers](http:
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
#### Encryption
|
#### Encryption
|
||||||
|
```js
|
||||||
var openpgp = require('openpgp');
|
var openpgp = require('openpgp');
|
||||||
var key = '-----BEGIN PGP PUBLIC KEY BLOCK ... END PGP PUBLIC KEY BLOCK-----';
|
var key = '-----BEGIN PGP PUBLIC KEY BLOCK ... END PGP PUBLIC KEY BLOCK-----';
|
||||||
var publicKey = openpgp.key.readArmored(key);
|
var publicKey = openpgp.key.readArmored(key);
|
||||||
openpgp.encryptMessage(publicKey.keys, 'Hello, World!').then(function(pgpMessage) {
|
openpgp.encryptMessage(publicKey.keys, 'Hello, World!').then(function(pgpMessage) {
|
||||||
// success
|
// success
|
||||||
}).catch(function(error) {
|
}).catch(function(error) {
|
||||||
// failure
|
// failure
|
||||||
});
|
});
|
||||||
|
```
|
||||||
|
|
||||||
#### Decryption
|
#### Decryption
|
||||||
|
```js
|
||||||
var openpgp = require('openpgp');
|
var openpgp = require('openpgp');
|
||||||
var key = '-----BEGIN PGP PRIVATE KEY BLOCK ... END PGP PRIVATE KEY BLOCK-----';
|
var key = '-----BEGIN PGP PRIVATE KEY BLOCK ... END PGP PRIVATE KEY BLOCK-----';
|
||||||
var privateKey = openpgp.key.readArmored(key).keys[0];
|
var privateKey = openpgp.key.readArmored(key).keys[0];
|
||||||
privateKey.decrypt('passphrase');
|
privateKey.decrypt('passphrase');
|
||||||
var pgpMessage = '-----BEGIN PGP MESSAGE ... END PGP MESSAGE-----';
|
var pgpMessage = '-----BEGIN PGP MESSAGE ... END PGP MESSAGE-----';
|
||||||
pgpMessage = openpgp.message.readArmored(pgpMessage);
|
pgpMessage = openpgp.message.readArmored(pgpMessage);
|
||||||
openpgp.decryptMessage(privateKey, pgpMessage).then(function(plaintext) {
|
openpgp.decryptMessage(privateKey, pgpMessage).then(function(plaintext) {
|
||||||
// success
|
// success
|
||||||
}).catch(function(error) {
|
}).catch(function(error) {
|
||||||
// failure
|
// failure
|
||||||
});
|
});
|
||||||
|
```
|
||||||
|
|
||||||
### Security recommendations
|
### Security recommendations
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user