mobilizon.chapril.org-mobil.../lib/mobilizon/crypto.ex

16 lines
358 B
Elixir
Raw Normal View History

2019-09-07 19:54:11 +02:00
defmodule Mobilizon.Crypto do
@moduledoc """
Utility module which contains cryptography related functions.
"""
@doc """
Returns random byte sequence of the length encoded to Base64.
"""
@spec random_string(integer) :: String.t()
def random_string(length) do
length
|> :crypto.strong_rand_bytes()
|> Base.url_encode64()
end
end