Created
October 5, 2011 04:17
-
-
Save pragmaticobjects/1263620 to your computer and use it in GitHub Desktop.
Generate random passwords and/or ids
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
| -module(random_password). | |
| -export([make_random_password/1]). | |
| make_random_password(N) -> | |
| {A1,A2,A3} = now(), | |
| random:seed(A1, A2, A3), | |
| lists:map(fun(_) -> make_random_unfunny_char() end, lists:seq(1, N)). | |
| make_random_unfunny_char() -> | |
| R = random:uniform(62), | |
| if | |
| % 1 to 10 | |
| R > 0 andalso R < 11 -> R - 1 + $0; | |
| % 11 to 36 | |
| R < 37 -> R - 11 + $A; | |
| % 37 to 62 | |
| true -> R - 37 + $a | |
| end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment