Skip to content

Instantly share code, notes, and snippets.

@tvdsluijs
Created August 8, 2012 05:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tvdsluijs/3292504 to your computer and use it in GitHub Desktop.
Save tvdsluijs/3292504 to your computer and use it in GitHub Desktop.
Flex AS3 Password Creator / Generator
public function createpw(strHash:String = 'abchefghjkmnpqrstuvwxyz0123456789',lnHash:Number = 5):String
{
var i:Number = 0;
var hash:String = "";
var nLenght:Number = strHash.length;
while (i <= lnHash)
{
var num:Number = Math.round(Math.random()*nLenght);
hash += strHash.charAt(num);
i++;
}
return hash;
}
@tvdsluijs
Copy link
Author

If you want createpw() to create a 5 letter password
txtField.text = createpw();

if you want createpw() to create a 4 digit password
txtField.text = createpw(‘1234567890’, 4);

if you want createpw() to generate 12 any character password
txtField.text = createpw('acbdefghijklmnopqrstuvwxyz1234567890!@#$%^&*()', 12);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment