Hi Paul,
var string specialChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
var string tempPassword;
var bool hasLowerCase = false;
var bool hasUpperCase = false;
var bool hasDigitSign = false;
var bool valid = true;
var int32 inx;
do{
// Desired number of signs in the resulting string
var int32 count = 6;
tempPassword = "";
// Compose the string of random characters
while ( count-- > 0 )
{
tempPassword += specialChars[ math_rand( 0, specialChars.length - 1 )];
}
//Validity check
for ( inx = 0; ( inx < tempPassword.length ); inx = inx + 1 )
{
var char c = tempPassword[inx];
hasLowerCase |= ( c >= 'a' ) && ( c <= 'z' );
hasUpperCase |= ( c >= 'A' ) && ( c <= 'Z' );
hasDigitSign |= ( c >= '0' ) && ( c <= '9' );
//hasSpecialChar |= specialChars.find( c, 0 ) >= 0;
}
valid = hasLowerCase && hasUpperCase && hasDigitSign ;
}
while(valid == false);
// 'tempPassword' contains the random string
trace tempPassword;
Here I am using validation check using the above method, But randomly it allows a string to exit from the loop without minimum of one lowercase or upper case or digit key.
For example If I generate a string "xRTdTu", it should be not validated but sometimes it is validating these type of strings as correct one. Why this behavior occurs randomly?
Regards,
Sazna.