dweb-encoding

2.0.0 • Public • Published

dweb-encoding

DWeb's way of encoding and decoding dweb links.

Build Status

Example

var encoding = require('dweb-encoding')

var link = '6161616161616161616161616161616161616161616161616161616161616161'
var buf = encoding.decode(link)
console.log('%s -> %s', link, buf)
console.log('%s -> %s', buf, encoding.encode(buf))

API

.encode(buf)

.toStr(buf)

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)

.toBuf(str)

Decode str into its binary representation. Also supports dweb:// and dweb.com/ links. Throws if the raw link isn't 64 bytes of base64.

If str is already a buffer, checks if it's valid and returns it.

License

MIT

/dweb-encoding/

    Package Sidebar

    Install

    npm i dweb-encoding

    Weekly Downloads

    1

    Version

    2.0.0

    License

    MIT

    Unpacked Size

    7.99 kB

    Total Files

    7

    Last publish

    Collaborators

    • shikhars3711