Feature request: Multihash
- Dominant language
- JavaScript
- Stars
- 35.8k
- Forks
- 4.1k
- Avg merge
- 2d 26m
- Merged PRs (30d)
- 33
Description
There's a standard for self-describing hashes called [Multihash](https://multiformats.io/multihash/).
A multihash follows the TLV (type-length-value) pattern.
- the type is an [unsigned variable integer](https://github.com/multiformats/unsigned-varint) identifying the hash function. There is a default table, and it is configurable. The default table is [the multicodec table](https://github.com/multiformats/multicodec/blob/master/table.csv).
- the length is an [unsigned variable integer](https://github.com/multiformats/unsigned-varint) counting the length of the digest, in bytes
- the value is the hash function digest, with a length of exactly bytes.
For example, the multihash value `122041dd7b6443542e75701aa98a0c235951a28a0d851b11564d20022ab11d2589a8` indicates:
- `12` indicates that the hash function variant is sha2-256
- `20` indicates that hash length is 32 bytes
- `41dd7b6443542e75701aa98a0c235951a28a0d851b11564d20022ab11d2589a8` is the hash value
This is already used in IPFS, but is intended for wider adoption to support portability and future-proofing.
It would be great to have an encoding block for producing a multihash of a byte string.
Contributor guide
Assessment
This issue has not been assessed yet.