dat-encoding

Encode and decode Dat links

MIT 19 个版本
安装
npm install dat-encoding
yarn add dat-encoding
pnpm add dat-encoding
bun add dat-encoding
README

deprecated See abstract-encoding and compact-encoding for similar functionality.

More info on active projects and modules at dat-ecosystem.org


dat-encoding

Dat's way of encoding and decoding dat links.

Build Status

Example

var encoding = require('dat-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 dat:// and dat.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

版本列表
5.0.2 2022-01-06
5.0.1 2017-12-11
5.0.0 2017-12-04
4.0.2 2017-02-08
4.0.1 2016-12-21
4.0.0 2016-12-20
3.0.2 2016-12-10
3.0.1 2016-09-24
3.0.0 2016-09-13
2.1.0 2016-09-12
2.0.2 2016-07-01
2.0.1 2016-06-20
2.0.0 2016-06-20
1.2.0 2016-06-20
1.1.2 2016-06-17
1.1.1 2016-06-17
1.1.0 2016-06-17
1.0.1 2016-06-17
1.0.0 2016-06-17