Cid (excid v1.0.0)
Provides a way for a user to turn a String, Map or Struct into a CID that is identical to one that will be returned from IPFS if the same data is added.
Currently only produces a default v1 CID. Currently only uses the "raw" codec Data provided must be under 256Kb in order for the CID to match the one returned by IPFS
For more info on CIDs and IPFS see the following... https://ipfs.io/ https://pascalprecht.github.io/posts/content-identifiers-in-ipfs/ https://github.com/dwyl/learn-ipfs/issues
Summary
Functions
Returns a CID that identical to one returned by IPFS if given the same data. Can take a String, Map or Struct as an argument.
Functions
cid(value)
Returns a CID that identical to one returned by IPFS if given the same data. Can take a String, Map or Struct as an argument.
Examples
iex> Application.put_env(:excid, :base, :base32) iex> Cid.cid("hello") "bafkreibm6jg3ux5qumhcn2b3flc3tyu6dmlb4xa7u5bf44yegnrjhc4yeq"
iex> Application.put_env(:excid, :base, :base58) iex> Cid.cid("hello") "zb2rhZfjRh2FHHB2RkHVEvL2vJnCTcu7kwRqgVsf9gpkLgteo"
iex> Application.put_env(:excid, :base, :base32) iex> Cid.cid(%{key: "value"}) "bafkreihehk6pgn2sisbzyajpsyz7swdc2izkswya2w6hgsftbgfz73l7gi"
iex> Application.put_env(:excid, :base, :base58) iex> Cid.cid(%{key: "value"}) "zb2rhn1C6ZDoX6rdgiqkqsaeK7RPKTBgEi8scchkf3xdsi8Bj"
iex> Cid.cid(1234) "invalid data type"
iex> Cid.cid([1,2,3,"four"]) "invalid data type"
iex> Application.put_env(:excid, :base, :wrong_base) iex> Cid.cid("hello") "invalid base"