View Source FatUtils.String (FatEcto v1.0.0)
Provides utility functions for generating random strings.
This module includes functions for generating random strings of specified lengths and from specific character sets.
Summary
Functions
Generates a random string of the specified length.
Generates a random string of the specified length using a custom character set.
Functions
@spec random(non_neg_integer()) :: binary()
Generates a random string of the specified length.
Parameters
length
: The length of the random string (default: 8).
Examples
iex> FatUtils.String.random()
"aB3dEfG1"
iex> FatUtils.String.random(12)
"xYz1aB2cD3eF"
random_of(length, char_set \\ ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"])
@spec random_of(non_neg_integer(), [String.t()]) :: binary()
Generates a random string of the specified length using a custom character set.
Parameters
length
: The length of the random string.char_set
: A list of characters to use for generating the string (default: A-Z).
Examples
iex> FatUtils.String.random_of(10)
"ABCDEFGHIJ"
iex> FatUtils.String.random_of(5, ["a", "b", "c"])
"abcba"