Skip to content

Commit 9aca150

Browse files
author
Tankred Hase
committed
Merge pull request openpgpjs#265 from yoshuawuyts/patch-1
readme: add syntax highlighting
2 parents eedb722 + 5ca1801 commit 9aca150

1 file changed

Lines changed: 23 additions & 22 deletions

File tree

README.md

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -33,30 +33,31 @@ OpenPGP.js uses ES6 promises which are available in [most modern browsers](http:
3333
### Examples
3434

3535
#### Encryption
36-
37-
var openpgp = require('openpgp');
38-
var key = '-----BEGIN PGP PUBLIC KEY BLOCK ... END PGP PUBLIC KEY BLOCK-----';
39-
var publicKey = openpgp.key.readArmored(key);
40-
openpgp.encryptMessage(publicKey.keys, 'Hello, World!').then(function(pgpMessage) {
41-
// success
42-
}).catch(function(error) {
43-
// failure
44-
});
36+
```js
37+
var openpgp = require('openpgp');
38+
var key = '-----BEGIN PGP PUBLIC KEY BLOCK ... END PGP PUBLIC KEY BLOCK-----';
39+
var publicKey = openpgp.key.readArmored(key);
40+
openpgp.encryptMessage(publicKey.keys, 'Hello, World!').then(function(pgpMessage) {
41+
// success
42+
}).catch(function(error) {
43+
// failure
44+
});
45+
```
4546

4647
#### Decryption
47-
48-
var openpgp = require('openpgp');
49-
var key = '-----BEGIN PGP PRIVATE KEY BLOCK ... END PGP PRIVATE KEY BLOCK-----';
50-
var privateKey = openpgp.key.readArmored(key).keys[0];
51-
privateKey.decrypt('passphrase');
52-
var pgpMessage = '-----BEGIN PGP MESSAGE ... END PGP MESSAGE-----';
53-
pgpMessage = openpgp.message.readArmored(pgpMessage);
54-
openpgp.decryptMessage(privateKey, pgpMessage).then(function(plaintext) {
55-
// success
56-
}).catch(function(error) {
57-
// failure
58-
});
59-
48+
```js
49+
var openpgp = require('openpgp');
50+
var key = '-----BEGIN PGP PRIVATE KEY BLOCK ... END PGP PRIVATE KEY BLOCK-----';
51+
var privateKey = openpgp.key.readArmored(key).keys[0];
52+
privateKey.decrypt('passphrase');
53+
var pgpMessage = '-----BEGIN PGP MESSAGE ... END PGP MESSAGE-----';
54+
pgpMessage = openpgp.message.readArmored(pgpMessage);
55+
openpgp.decryptMessage(privateKey, pgpMessage).then(function(plaintext) {
56+
// success
57+
}).catch(function(error) {
58+
// failure
59+
});
60+
```
6061

6162
### Security recommendations
6263

0 commit comments

Comments
 (0)