Generate random strings.
Add random_bytes
to your list of dependencies in mix.exs
:
def deps do
[{:random_bytes, "~> 1.0"}]
end
Generate a random base62 string:
iex> RandomBytes.base62
"HMVrjeb1GvIPSlqVbZhHig"
iex> RandomBytes.base62(28)
"KDGpJ5xQsQSTnIUZN4CZcetG3yDSZXWzrwM6BA"
iex> RandomBytes.base62(9)
"88XuyJDWK2LA"
Generate a random base16 string:
iex> RandomBytes.base16
"e1d227efd5ae7d359fb6a3fff23ae44e"
iex> RandomBytes.base16(4)
"bc859e88"
Generate a UUID:
iex> RandomBytes.uuid
"6c2bc294-a8f4-4d64-8fb4-5fda8b1d7763"
RandomBytes source code is released under the Apache 2 License (same as Elixir). Check LICENSE file for more information.