Groovy web console

subscribe to the feed Subscribe
to this
site

password generator

Published 3 months ago by Anonymous
Actions Execute script  ▶ Edit in console Back to console Show/hide line numbers View recent scripts
def pass_length = 10;
def special = ['~' ,'`', '#', '*', '&'] // you get the idea...
def pool = ['a'..'z','A'..'Z',0..9,'_'].flatten().plus(special);
Random rand = new Random(System.currentTimeMillis());

def passChars = (0..pass_length - 1).collect { pool[rand.nextInt(pool.size())] };
passChars[rand.nextInt(passChars.size())] = special[rand.nextInt(special.size())]
return passChars.join();