Strong Password Generator

Here is some code I put together for a project I am working on that I thought might be useful to some other folks on the forum. This will generate a strong password containing a random order combination of 4 upper case characters, 5 lower case characters, six numbers and 2 special characters. These individual amounts can easily be changed in the code to meet your needs. I was going to put in an alert to ask if you wanted to include the special characters but I will leave that up to you if you so desire. Allowed special characters can vary by site so I included just some basic ones.

	//create main variable
let pword=""
	//create core password (9 alpha characters & 6 numbers)
createpassword 9, 6,"", pword
	//isolate all the alpha characters from pword
let charac=striptoalpha(pword)
	//convert to 4 upper case & 5 lower case alpha characters
	//isolate numbers from pword & add 2 special characters
let numb=striptonum(pword)+
    array("!,#,^,*,_,(,{,},),|",randominteger(1, 10),",")+
    array("!,#,^,*,_,(,{,},),|",randominteger(1, 10),",")
	//combine numbers & special characters with alphas
	//add comma separators between each character
characterfilter pword, pword, import()+","
	//remove trailing separator & randomize string
pword=arrayrandomize(pword[1,-2], ",")
	//remove the temporary comma separators
	//assign new password to the Password field
Password= pword

The createpassword statement has no provisions for adding special characters nor does it guarantee a mix of both upper and lower case letters using the “” option as the third parameter. This code assigns the password to a field called Password but can be anything needed including the clipboard.

1 Like