Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dekosuke/888306 to your computer and use it in GitHub Desktop.
Save dekosuke/888306 to your computer and use it in GitHub Desktop.
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
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"
print"".join([map(chr,range(65,91)+range(97,123)+range(48,58)+[95])[id(i)%64] for
i in range(16)])
import System.Random
alnum = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"
int2alnum x= (!!) alnum $ (mod (abs x) 64)
main = do
gen <- newStdGen
let ns = randoms gen :: [Int]
print $ map int2alnum (take 16 ns)
def array = (0..9) + ('a'..'z') + ('A'..'Z') + '_'
def getRandomChar = {
array.with {
Collections.shuffle(it)
head()
}
}
println(
(1..16).collect{ getRandomChar() }.join()
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment