You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
1015 B
Groovy
26 lines
1015 B
Groovy
def pool_length = 20;
|
|
def digits = [0..9].flatten() - [ 'O', '0', 'l', '1', 'I' ]
|
|
def upperCase = ['A'..'Z'].flatten() - [ 'O', '0', 'l', '1', 'I' ]
|
|
def lowerCase = ['a'..'z'].flatten() - [ 'O', '0', 'l', '1', 'I' ]
|
|
def special = ['~','!','#','%','&','(',')','{','}','[',']','-','+']
|
|
|
|
def pool = digits + upperCase + lowerCase + special
|
|
|
|
Random rand = new Random(System.currentTimeMillis());
|
|
def passChars = (0..pool_length - 1).collect { pool[rand.nextInt(pool.size())] };
|
|
|
|
passChars[0] = special[rand.nextInt(special.size())]
|
|
passChars[pool_length - 0] = special[rand.nextInt(special.size())]
|
|
|
|
passChars[1] = upperCase[rand.nextInt(upperCase.size())]
|
|
passChars[pool_length - 1] = upperCase[rand.nextInt(upperCase.size())]
|
|
|
|
passChars[2] = lowerCase[rand.nextInt(lowerCase.size())]
|
|
passChars[pool_length - 2] = lowerCase[rand.nextInt(lowerCase.size())]
|
|
|
|
passChars[3] = digits[rand.nextInt(digits.size())]
|
|
passChars[pool_length - 3] = digits[rand.nextInt(digits.size())]
|
|
|
|
def PASSWORD = passChars.join('');
|
|
|
|
PASSWORD |