Fakultas Ilmu Komputer UI

Skip to content
Snippets Groups Projects
Commit e9537db8 authored by Muhammad Rafif Elfazri's avatar Muhammad Rafif Elfazri
Browse files

add random string function

parent 55b4be99
No related branches found
No related tags found
No related merge requests found
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment