comfycamp/lib/comfycamp/rand.ex

9 lines
256 B
Elixir

defmodule Comfycamp.Rand do
@chars "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" |> String.codepoints()
def get_random_string(length) do
1..length
|> Enum.map(fn _i -> Enum.random(@chars) end)
|> Enum.join("")
end
end