View Source Slip39.Utils (slip39 v0.1.1)
Summary
Functions
Round up bit count to whole bytes.
Chunk the given bitstring into an array of bitstring of n length.
When an enum needs to be accessed by its index, this function gives an efficient way and cleaner syntax to do it.
Round up an integer to the next multiple given a second argument
Return a random share definition. This is mainly used for testing.
Randomness source for the module. If deterministic testing is needed, one can configure the source for test MIX_ENV here in future revision.
Functions
Round up bit count to whole bytes.
iex(1)> Slip39.Utils.bits_to_bytes(9)
2
Chunk the given bitstring into an array of bitstring of n length.
iex(1)> Slip39.Utils.chunk_bits(<<1::1, 1::1, 1::1, 1::1>>,2)
[<<3::size(2)>>, <<3::size(2)>>]
When an enum needs to be accessed by its index, this function gives an efficient way and cleaner syntax to do it.
iex(1)> my_data = ["zero", "one", "two"]
["zero", "one", "two"]
iex(2)> my_indexed_data = Slip39.Utils.enum_to_indexed_map(my_data)
%{0 => "zero", 1 => "one", 2 => "two"}
iex(3)> my_indexed_data[2]
"two"
Round up an integer to the next multiple given a second argument
iex(1)> Slip39.Utils.nearest_upper_multiple(41, 10)
50
Randomness source for the module. If deterministic testing is needed, one can configure the source for test MIX_ENV here in future revision.