BSV-ex v0.3.0 BSV.Util View Source
A collection of commonly used helper methods.
Link to this section Summary
Functions
Decodes the given binary data with the specified encoding scheme.
Encodes the given binary data with the specified encoding scheme.
Generates random bits for the given number of bytes.
Reverses the order of the given binary data.
Link to this section Functions
Decodes the given binary data with the specified encoding scheme.
Options
The accepted encoding schemes are:
:base64
- Encodes the binary using Base64:hex
- Encodes the binary using Base16 (hexidecimal), using lower character case
Examples
iex> BSV.Util.decode("aGVsbG8gd29ybGQ=", :base64)
"hello world"
iex> BSV.Util.decode("68656c6c6f20776f726c64", :hex)
"hello world"
Encodes the given binary data with the specified encoding scheme.
Options
The accepted encoding schemes are:
:base64
- Encodes the binary using Base64:hex
- Encodes the binary using Base16 (hexidecimal), using lower character case
Examples
iex> BSV.Util.encode("hello world", :base64)
"aGVsbG8gd29ybGQ="
iex> BSV.Util.encode("hello world", :hex)
"68656c6c6f20776f726c64"
Generates random bits for the given number of bytes.
Examples
iex> iv = BSV.Util.random_bytes(16)
...> bit_size(iv)
128
Reverses the order of the given binary data.
Examples
iex> BSV.Util.reverse_bin("abcdefg")
"gfedcba"