-
Notifications
You must be signed in to change notification settings - Fork 10
dWeb Codec
Jared Rice Sr edited this page Jun 28, 2018
·
1 revision
dWeb's way of encoding and decoding dPack keys. Which are in turn, dWeb addresses.
npm install @dwebs/codec
yarn add @dwebs/codec
var dWebCreateAddress = require('@dwebs/codec')
var dWebLink = '25097091325097097135098983593802'
var dWebLinkBuffer = dWebAddressEncode.dWebAddressDecode(dWebLink)
console.log('%s -> %s', dWebLink, dWebLinkBuffer)
console.log('%s -> %s', dWebLinkBuffer, dWebCreateAddress.dWebAddressEncode(dWebLinkBuffer))
Encode buf
into a hex string. Throws if buf
isn't 32 bytes of length.
If buf
is already a string, checks if it's valid and returns it.
Decode str
into its binary representation.
If str
is already a buffer, checks if it's valid and returns it.