Add syntax highlighting to README

This commit is contained in:
Maciej Krüger 2017-12-06 13:40:12 +01:00 committed by GitHub
parent cfdd2f47bf
commit 643bcd4eb2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -29,18 +29,22 @@
## Install ## Install
npm install --save libp2p-keychain ```sh
npm install --save libp2p-keychain
```
### Usage ### Usage
const Keychain = require('libp2p-keychain') ```js
const FsStore = require('datastore-fs') const Keychain = require('libp2p-keychain')
const FsStore = require('datastore-fs')
const datastore = new FsStore('./a-keystore') const datastore = new FsStore('./a-keystore')
const opts = { const opts = {
passPhrase: 'some long easily remembered phrase' passPhrase: 'some long easily remembered phrase'
} }
const keychain = new Keychain(datastore, opts) const keychain = new Keychain(datastore, opts)
```
## API ## API
@ -68,7 +72,7 @@ Cryptographically protected messages
The key management and naming service API all return a `KeyInfo` object. The `id` is a universally unique identifier for the key. The `name` is local to the key chain. The key management and naming service API all return a `KeyInfo` object. The `id` is a universally unique identifier for the key. The `name` is local to the key chain.
``` ```js
{ {
name: 'rsa-key', name: 'rsa-key',
id: 'QmYWYSUZ4PV6MRFYpdtEDJBiGs4UrmE6g8wmAWSePekXVW' id: 'QmYWYSUZ4PV6MRFYpdtEDJBiGs4UrmE6g8wmAWSePekXVW'
@ -82,7 +86,7 @@ The **key id** is the SHA-256 [multihash](https://github.com/multiformats/multih
A private key is stored as an encrypted PKCS 8 structure in the PEM format. It is protected by a key generated from the key chain's *passPhrase* using **PBKDF2**. Its file extension is `.p8`. A private key is stored as an encrypted PKCS 8 structure in the PEM format. It is protected by a key generated from the key chain's *passPhrase* using **PBKDF2**. Its file extension is `.p8`.
The default options for generating the derived encryption key are in the `dek` object The default options for generating the derived encryption key are in the `dek` object
``` ```js
const defaultOptions = { const defaultOptions = {
createIfNeeded: true, createIfNeeded: true,