multihash.digest

Digest functions for creating new multihash constructors.

defhash

macro

(defhash algorithm digest-name)

Defines a new convenience hashing function for the given algorithm and system digest name.

functions

Map of supported multihash algorithm keys to hashing functions. Each function should take a source of binary data as the argument and return a multihash.

sha1

(sha1 content)

Calculates the SHA-1 digest of the given byte array or buffer and returns a multihash.

sha2-256

(sha2-256 content)

Calculates the SHA-256 digest of the given byte array or buffer and returns a multihash.

sha2-512

(sha2-512 content)

Calculates the SHA-512 digest of the given byte array or buffer and returns a multihash.

test

(test mhash content)

Determines whether a multihash is a correct identifier for some content by recomputing the digest for the algorithm specified in the multihash. Returns nil if either argument is nil, true if the digest matches, or false if not. Throws an exception if the multihash specifies an unsupported algorithm.