Created
April 2, 2019 12:12
-
-
Save zacck-zz/c9e0262a29080396bcf273f9fe50080a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@chars "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890-_?" |> String.split("", trim: true) | |
@spec generate_hash(integer()) :: String.t() | |
def generate_hash(length) do | |
Enum.reduce((1..length), [], fn (_i, acc) -> | |
[Enum.random(@chars) | acc] | |
end) |> Enum.join("") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment