package multihash

Import Path
	github.com/multiformats/go-multihash (on go.dev)

Dependency Relation
	imports 11 packages, and imported by 5 packages

Involved Source Files io.go Package multihash is the Go implementation of https://github.com/multiformats/multihash, or self-describing hashes. registry.go set.go sum.go
Package-Level Type Names (total 6)
/* sort by: | */
DecodedMultihash represents a parsed multihash and allows easy access to the different parts of a multihash. Code uint64 // Digest holds the raw multihash bytes // Length is just int as it is type of len() opearator Name string func Decode(buf []byte) (*DecodedMultihash, error)
ErrInconsistentLen is returned when a decoded multihash has an inconsistent length ( ErrInconsistentLen) Error() string ErrInconsistentLen : error
Multihash is byte slice with the following form: <hash function code><digest size><hash function output>. See the spec for more information. B58String returns the B58-encoded representation of a multihash. HexString returns the hex-encoded representation of a multihash. String is an alias to HexString(). Multihash : expvar.Var Multihash : fmt.Stringer func Cast(buf []byte) (Multihash, error) func FromB58String(s string) (m Multihash, err error) func FromHexString(s string) (Multihash, error) func MHFromBytes(buf []byte) (int, Multihash, error) func Sum(data []byte, code uint64, length int) (Multihash, error) func SumStream(r io.Reader, code uint64, length int) (Multihash, error) func Reader.ReadMultihash() (Multihash, error) func (*Set).All() []Multihash func github.com/ipfs/go-cid.Cid.Hash() Multihash func (*Set).Add(m Multihash) func (*Set).Has(m Multihash) bool func (*Set).Remove(m Multihash) func (*Set).Visit(m Multihash) bool func Writer.WriteMultihash(Multihash) error func github.com/ipfs/go-cid.NewCidV0(mhash Multihash) cid.Cid func github.com/ipfs/go-cid.NewCidV1(codecType uint64, mhash Multihash) cid.Cid
Reader is an io.Reader wrapper that exposes a function to read a whole multihash, parse it, and return it. ( Reader) Read(p []byte) (n int, err error) ( Reader) ReadMultihash() (Multihash, error) Reader : io.Reader func NewReader(r io.Reader) Reader
Set is a set of Multihashes, holding one copy per Multihash. Add adds a new multihash to the set. All returns a slice with all the elements in the set. ForEach runs f(m) with each multihash in the set. If returns immediately if f(m) returns an error. Has returns true if the element is in the set. Len returns the number of elements in the set. Remove removes an element from the set. Visit adds a multihash only if it is not in the set already. Returns true if the multihash was added (was not in the set before). func NewSet() *Set
Writer is an io.Writer wrapper that exposes a function to write a whole multihash. ( Writer) Write([]byte) (int, error) ( Writer) WriteMultihash(Multihash) error Writer : github.com/miekg/dns.Writer Writer : internal/bisect.Writer Writer : io.Writer func NewWriter(w io.Writer) Writer
Package-Level Functions (total 14)
Cast casts a buffer onto a multihash, and returns an error if it does not work.
Decode parses multihash bytes into a DecodedMultihash.
Encode a hash digest along with the specified function code. Note: the length is derived from the length of the digest itself. The error return is legacy; it is always nil.
EncodeName is like Encode() but providing a string name instead of a numeric code. See Names for allowed values.
FromB58String parses a B58-encoded multihash.
FromHexString parses a hex-encoded multihash.
Register is an alias for Register in the core package. Consider using the core package instead of this multihash package; that package does not introduce transitive dependencies except for those you opt into, and will can result in smaller application builds.
MHFromBytes reads a multihash from the given byte buffer, returning the number of bytes read as well as the multihash
NewReader wraps an io.Reader with a multihash.Reader
NewSet creates a new set correctly initialized.
NewWriter wraps an io.Writer with a multihash.Writer
Register is an alias for Register in the core package. Consider using the core package instead of this multihash package; that package does not introduce transitive dependencies except for those you opt into, and will can result in smaller application builds.
Sum obtains the cryptographic sum of a given buffer. The length parameter indicates the length of the resulting digest. Passing a negative value uses default length values for the selected hash function.
SumStream obtains the cryptographic sum of a given stream. The length parameter indicates the length of the resulting digest. Passing a negative value uses default length values for the selected hash function.
Package-Level Variables (total 12)
Codes maps a hash code to it's name
DefaultLengths maps a multihash indicator code to the output size for that hash, in units of bytes.
ErrSumNotSupported is returned when the Sum function code is not implemented
errors
errors
errors
errors
Names maps the name of a hash to the code
Package-Level Constants (total 28)
constants
constants
constants
constants
constants
constants
Deprecated: use IDENTITY
constants
constants
constants
constants
constants
constants
Deprecated: use MURMUR3X64_64
constants
constants
constants
constants
constants
constants
constants
constants
constants
constants
constants
constants
constants
constants