multihash.core

Core multihash type definition and helper methods.

algorithm-codes

Map of information about the available content hashing algorithms.

app-code?

(app-code? code)

True if the given code number is assigned to the application-specfic range. Returns nil if the argument is not an integer.

base58

(base58 mhash)

Encodes a multihash into a Base-58 string.

create

(create algorithm digest)

Constructs a new Multihash identifier. Accepts either a numeric algorithm code or a keyword name as the first argument. The digest may either by a byte array or a hex string.

Decodable

protocol

This protocol provides a method for data sources which a multihash can be read from.

members

decode

(decode source)

Attempts to read a multihash value from the data source.

decode-array

(decode-array encoded)

Decodes a byte array directly into multihash. Throws ex-info with a :type of :multihash/bad-input if the data is malformed or invalid.

encode

(encode mhash)

Encodes a multihash into a binary representation.

get-algorithm

(get-algorithm value)

Looks up an algorithm by keyword name or code number. Returns nil if the value does not map to any valid algorithm.

hex

(hex mhash)

Encodes a multihash into a hexadecimal string.