exth_crypto v0.1.6 ExthCrypto.Hash

A variety of functions to handle one-way hashing functions as defined by Ethereum.

Link to this section Summary

Functions

Runs the specified hash type on the given data

Returns a list of supported hash algorithms

The KECCAK hasher, as defined by Ethereum

The SHA1 hasher

Link to this section Types

Link to this type hash()
hash() :: binary()
Link to this type hash_algorithm()
hash_algorithm() :: atom()
Link to this type hash_type()
hash_type() :: {hasher(), integer() | nil, integer()}
Link to this type hasher()
hasher() :: (binary() -> binary())

Link to this section Functions

Link to this function hash(data, hasher)
hash(iodata(), hash_type()) :: hash()

Runs the specified hash type on the given data.

Examples

iex> ExthCrypto.Hash.hash("hello world", ExthCrypto.Hash.kec) |> ExthCrypto.Math.bin_to_hex
"47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad"

iex> ExthCrypto.Hash.hash("hello world", ExthCrypto.Hash.sha1) |> ExthCrypto.Math.bin_to_hex
"2aae6c35c94fcfb415dbe95f408b9ce91ee846ed"
Link to this function hash_algorithms()
hash_algorithms() :: [hash_algorithm()]

Returns a list of supported hash algorithms.

Link to this function kec()
kec() :: ExCrpyto.hash_type()

The KECCAK hasher, as defined by Ethereum.

The SHA1 hasher.