How to customize how to obtain password strength in C language
In order to solve the problem of how to customize how to obtain password strength in C language, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and easy way.
Generally, when entering a password when registering, there will be a judgment of password strength. Passwords can be judged by general rules according to character type and length.
# include # include # define PASSWD_STRONG_MIN_LENGTH 10typedef enum {PASSWORD_INVALID=0, PASSWORD_WEAK, PASSWORD_NORMAL, PASSWORD_STRONG} PasswordStrength;PasswordStrength GetPasswordStrength (char * password) {if (password = = NULL) {return PASSWORD_INVALID;} int iSymbol=0,iNumber=0,iLetter=0; int passwd_len=0; char * pChar=password; passwd_len= strlen (password) If (passwd_len
< 6){ /*密码字符数小于6不满足规则,无效密码*/ return PASSWORD_INVALID; } for(;*pChar != '\0';pChar++){ if(*pChar >='0' & & * pChar ='A'& & * pChar ='a'& & * pChar