multiformats

Multiformats for IPFS content identifier (CID). Includes base32 and leb128 helpers

Package Version Hex Docs

Currently only the sha256 hasher is supported.

gleam add multiformats@1
import dag_json
import multiformats/cid
import multiformats/hashes.{Multihash, Sha256}

pub fn main() {
  let data = // some json
  let bytes = dag_json.encode(data)
  let hashed = todo as "sha256 digest"
  let multihash = Multihash(Sha256,hashed)
  cid.create_v1(dag_json.code(), multihash)
  |> cid.to_string
}

Further documentation can be found at https://hexdocs.pm/multiformats.

Explore CID’s

https://cid.ipfs.tech/

Hashing

The actual hashing process depends on the platform you are running on. If running in the browser, plinth is recommended. For both node and erlang, gleam_crypto is recommended.

Development

gleam run   # Run the project
gleam test  # Run the tests

Credit

Created for EYG, a new integration focused programming language.

Search Document