|
-
September 13th, 2006, 01:38 AM
#1
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
-
September 13th, 2006, 02:42 AM
#2
Re: implementing password complexity
I did not get : what do you want exactly? Validations ?
Can you help me with my homework assignment?, Before you post!, Use code tags, How to post!, Codeguru technical FAQs, C++ FAQ Lite, Stroustrup: C++ Style and Technique FAQ, Guru of the Week, Comeau C and C++ FAQs, Comeau C++ Templates FAQs, CUJ @ DDJ, Spam threshold
My Blogs : Learning C++ is fun | Abnegator's reflections
Open Threads : C++ Aha! Moments | Nature of work in C++?
-
September 13th, 2006, 03:25 AM
#3
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.
Correct is better than fast. Simple is better than complex. Clear is better than cute. Safe is better than insecure.
-- Sutter and Alexandrescu, C++ Coding Standards
Programs must be written for people to read, and only incidentally for machines to execute.
-- Harold Abelson and Gerald Jay Sussman
The cheapest, fastest and most reliable components of a computer system are those that aren't there.
-- Gordon Bell
-
September 13th, 2006, 07:40 AM
#4
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|