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.
hetzner-ansible/smardigo/pmci/script/create-low-string.groovy

14 lines
450 B
Groovy

def pool_length = in_length?:10;
def lowerCase = ['a'..'z'].flatten() - [ 'O', '0', 'l', '1', 'I' ]
def pool = lowerCase
Random rand = new Random(System.currentTimeMillis());
def passChars = (0..pool_length - 1).collect { pool[rand.nextInt(pool.size())] };
passChars[0] = lowerCase[rand.nextInt(lowerCase.size())]
passChars[pool_length - 2] = lowerCase[rand.nextInt(lowerCase.size())]
def low_string = passChars.join('');
low_string