implementing password complexity
hi can i get help to write code for password complexity?when a user logs in,the code should check for something like this:
while(*pw){
if( *pw => 'A' && *pw <= 'Z' )
uc=1;
else if( *pw >= 'a' && *pw <= 'z' )
lc=1;
else if( *pw >= '0' && *pw <= '9' )
num=1;
pw++;
}
the code should also check for a minlen of 6 and maxlen of 12.
thanks
Re: implementing password complexity
I did not get : what do you want exactly? Validations ?
Re: implementing password complexity
I think he's looking to check that a password meets minimum criteria - e.g. at least one uppercase char, at least one digit, etc. The code given is a reasonable start - I'd use bools instead of ints, though.
Re: implementing password complexity
Also add a check for the length of the password so it meets the length requirements.
Code:
int pwLen = strlen( pw );
if( pwLen < 6 )
//password to short
if( pwLen > 12 )
// password to long
May want to check the length before checking that the password meets the complexity requirements.