A C++ programme to check the strength of a password. A password must pass some criteria to be a strong password.
Function int valid ( ) checks if the password is valid or not :
int val::valid (char p[],int n) { a=b=c=0; for(int i=0;i<n;i++) { if(isdigit(p[i])) { a+=1; //counts the number of digits in the entered password } for (int j=0;j<7;j++) { if(p[i]==x[j]) { b+=1; //counts the number of special characters in the entered password } } c+=1; //counts the number of total characters in the entered password } if(a>=2&&b>=2&&c>=7) { cout<<"STRONG\nPassword saved successfully!"; return 1; } else { cout<<"\aWEAK\n"; if(a<2) cout<<"The password must contain at least 2 digits!\n"; if(b<2) cout<<"The password must contain at least 2 of the following special characters ('!', '@', '#', '$', '%', '&', '*')\n"; if(c<7) cout<<"The password must contain at least 7 characters\n"; return 0; } }
Submitted by Srishti Dhaval Patkar (srishtipatkar15)
Download packets of source code on Coders Packet
Comments