Revision: 49378
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at July 21, 2011 00:26 by adrianparr
Initial Code
function createRandomPassword(hashLen:uint, includeLowercase:Boolean = true, includeNumbers:Boolean = true, includeUppercase:Boolean = false):String {
var strHash:String = "";
if (includeLowercase) strHash += "abchefghjkmnpqrstuvwxyz";
if (includeNumbers) strHash += "0123456789";
if (includeUppercase) strHash += "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var maskPick:Number;
var passwordStr:String = "";
var maskLen:uint = strHash.length;
for (var i:uint = 0; i < hashLen; i++) {
maskPick = Math.floor(Math.random() * maskLen);
passwordStr += strHash.charAt(maskPick);
}
return passwordStr;
}
trace(createRandomPassword(8));
// Output
// 6k3x10h8j
trace(createRandomPassword(6, true, true, true));
// Output
// D2jHEfT
trace(createRandomPassword(16, false, true, true));
// Output
// O8I2DTSLHHWRI50Z
trace(createRandomPassword(16, true, false, false));
// Output
// xxfeyshhqkrsqvhjt
trace(createRandomPassword(16, false, false, true));
// Output
// XMXIDTIXMNGNUXZT
trace(createRandomPassword(16, false, true, false));
// Output
// 4026352375069424
Initial URL
Initial Description
Based upon this (https://gist.github.com/988479) but made a few fixes.
Initial Title
AS3 Create Random Password
Initial Tags
Initial Language
ActionScript 3