From 76f14288720551f76f23a4511a41d1af35f8f249 Mon Sep 17 00:00:00 2001
From: Friedel Ziegelmayer
<script src="https://unpkg.com/peer-id/dist/index.min.js"></script>
<!-- OR -->
<script src="https://unpkg.com/peer-id/dist/index.js"></script>
-A Peer ID is the SHA-256 multihash of a public key.
create(opts: Object?, callback: function (Error, PeerId))
Create a new PeerId
by generating a new public/private keypair.
create(opts: Object?, callback: function (Error, PeerId))
Create a new PeerId
by generating a new public/private keypair.
Name | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts: Object? | Configuration object. | ||||||||||||||||
opts.bits: number? (=2048) | How many bits to use for the RSA key generation. | ||||||||||||||||
callback: function (Error, PeerId) | Node.js style callback.
@@ -81,44 +81,44 @@ PeerId.create((err, idthrow err
}
console.log('id', JSON.stringify(id))
-})PeerId.createFromHexString
Creates a Peer ID from hex string representing the key's multihash. +})PeerId.createFromHexString
Creates a Peer ID from hex string representing the key's multihash. Parameters
ReturnsPeerId
-PeerId.createFromBytes
Creates a Peer ID from a buffer representing the key's multihash. +PeerId.createFromBytes
Creates a Peer ID from a buffer representing the key's multihash. Parameters
ReturnsPeerId
-PeerId.createFromB58String
Creates a Peer ID from a PeerId.createFromB58String
Creates a Peer ID from a Parameters
ReturnsPeerId
-PeerId.createFromPubKey
Creates a Peer ID from a buffer containing a public key. -PeerId.createFromPrivKey
Creates a Peer ID from a buffer containing a private key. +PeerId.createFromPubKey
Creates a Peer ID from a buffer containing a public key. +PeerId.createFromPrivKey
Creates a Peer ID from a buffer containing a private key. PeerId.createFromJSON
Import a Parameters
|
createFromJSON(obj: PeerIdJson, callback: function (Error, PeerId))
Import a PeerId
from a serialized JSON object.
Name | Description |
---|---|
obj: PeerIdJson |
constructor(id: Buffer, privKey: RSAPrivateKey?, pubKey: RSAPublickKey?)
Name | Description |
---|---|
id: Buffer | |
privKey: RSAPrivateKey? | |
pubKey: RSAPublickKey? |
id: Buffer
toJSON(): PeerIdJson
Return the jsonified version of the key, matching the formatting of go-ipfs for its config file.