-
-
Save nikolat/823786 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
def array = [] | |
def tmp = "" | |
array = ('0'..'9') + ('a'..'z') + ('A'..'Z') + '_' | |
(1..16).each { | |
tmp += array[Math.floor(Math.random() * array.size()) as int] | |
} | |
println tmp |
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
array = [] | |
tmp = "" | |
array = ('0'..'9').to_a + ('a'..'z').to_a + ('A'..'Z').to_a + '_'.to_a | |
(1..16).each { | |
tmp += array[rand(array.size())] | |
} | |
print tmp + "\n" |
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 array = (0..9) + ('a'..'z') + ('A'..'Z') + '_' | |
def getRandomChar = { | |
array.with { | |
Collections.shuffle(it) | |
head() | |
} | |
} | |
println( | |
(1..16).collect{ getRandomChar() }.join() | |
) |
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
import string | |
import random | |
def getRandomAlphabetNum(n): | |
elements = string.digits + string.letters + '_' | |
return ''.join(random.choice(elements) for i in xrange(n)) | |
if __name__ == '__main__': | |
print getRandomAlphabetNum(16) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment