Created
August 8, 2012 05:44
-
-
Save tvdsluijs/3292504 to your computer and use it in GitHub Desktop.
Flex AS3 Password Creator / Generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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);