E9.2 Groovy Script to generate Random string for Password

EggyPaw

Active Member
Hey Community ,

Need help in how to generate a random alphanumerical string in a groovy script ? Want to include this in an orchestration for user creation where i will generate a random password for users and email it to them

Thank you
 
Here's one I found via google and stackoverflow that I thought was interesting. Should be quick to convert this into an orchestration scripting component



JavaScript:
def pass_length = 15;

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)] };

def specialChar = special[rand.nextInt(special.size)]

passChars[rand.nextInt(passChars.size)] = specialChar

def PASSWORD = passChars.join();
 
Thanks Dave but I'm looking for a groovy script , we recenlty upgraded to 9.2.6 and it seems there's no more javascript
 
This is groovy-- I just chose javascript on this forum to format the code and make it pretty. :)
 
Back
Top