Fakultas Ilmu Komputer UI

Commit e9537db8 authored by Muhammad Rafif Elfazri's avatar Muhammad Rafif Elfazri
Browse files

add random string function

parent 55b4be99
......@@ -3,4 +3,10 @@ defmodule Diskuy.Utility.Utility do
text_list = String.split(text, " ", trim: true)
Enum.map_join(text_list, " ", &String.capitalize/1)
end
@spec random_string(non_neg_integer) :: binary
def random_string(length) do
:crypto.strong_rand_bytes(length) |> Base.encode64 |> binary_part(0, length)
end
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment