Created
November 15, 2013 17:06
-
-
Save demoth/7487896 to your computer and use it in GitHub Desktop.
Simple random string generator. Found on http://stackoverflow.com/a/8138604/1928171 by tim_yates
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
def generator = { String alphabet, int n -> | |
new Random().with { | |
(1..n).collect { alphabet[nextInt(alphabet.length())] }.join('') | |
} | |
} | |
def alphabet = (('А'..'Я') + ('а'..'я') + ('0'..'9')).join('') | |
println generator(alphabet, 10) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment