Kryptonite v0.1.11 Kryptonite.Random View Source
This module provides helper functions related to generating data at random.
Link to this section Summary
Functions
Returns a string at random where the length is equal to length
Returns a string at random where the length is equal to length
.
Essentially the same as bytes!/1
but returns a tuple on error
instead of raising
Hashes a given digest
over itself for as many times as specified by count
Calculates the entropy rating of a given binary
Link to this section Functions
Returns a string at random where the length is equal to length
.
Examples
iex> data = bytes!(16)
iex> {byte_size(data), bit_size(data)}
{16, 128}
iex> data = bytes!(32)
iex> {byte_size(data), bit_size(data)}
{32, 256}
Returns a string at random where the length is equal to length
.
Essentially the same as bytes!/1
but returns a tuple on error
instead of raising.
Examples
iex> data = bytes!(16)
iex> {byte_size(data), bit_size(data)}
{16, 128}
iex> bytes(-1)
{:error, :badarg}
Link to this function
hash_round(digest, count)
View Source
hash_round(binary(), pos_integer()) :: <<_::512>>
Hashes a given digest
over itself for as many times as specified by count
.
Examples
iex> m = "Some message."
iex> hash_round(m, 1) == hash_round(m, 2)
false
iex> hash_round(m, 2) == m |> hash_round(1) |> hash_round(1)
true