W3WS.Util (w3ws v0.1.0)

Utility functions

Summary

Functions

Convert a hex string to a binary

Convert a hex string to an integer

Calculate the keccak256 hash of a binary, optionally encoding as hex

Convert a binary to hex

Functions

@spec from_hex(String.t()) :: binary()

Convert a hex string to a binary

Examples

iex> from_hex("0x010203")
<<1, 2, 3>>

iex> from_hex("0x")
""

iex> from_hex("")
""
Link to this function

integer_from_hex(arg)

@spec integer_from_hex(String.t()) :: integer()

Convert a hex string to an integer

Examples

iex> integer_from_hex("0x7")
7
Link to this function

keccak(binary, opts \\ [])

@spec keccak(binary(), Keyword.t()) :: String.t()

Calculate the keccak256 hash of a binary, optionally encoding as hex

Examples

iex> keccak("foo", hex?: true)
"0x41b1a0649752af1b28b3dc29a1556eee781e4a4c3a1f7f53f90fa834de098c4d"
@spec to_hex(binary()) :: String.t()

Convert a binary to hex

Examples

iex> to_hex(<<1, 2, 3>>)
"0x010203"