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
Link to this function

chunk_bits(bitstring, n)

View Source
@spec chunk_bits(bitstring(), any()) :: [bitstring()]

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)>>]
Link to this function

enum_to_indexed_map(enum)

View Source

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"
Link to this function

is_string_only_ascii(string)

View Source
Link to this function

nearest_upper_multiple(n, multiple)

View Source
@spec nearest_upper_multiple(integer(), integer()) :: integer()

Round up an integer to the next multiple given a second argument

iex(1)> Slip39.Utils.nearest_upper_multiple(41, 10)
50

Return a random share definition. This is mainly used for testing.

@spec rnd_bytes(integer()) :: binary()

Randomness source for the module. If deterministic testing is needed, one can configure the source for test MIX_ENV here in future revision.