Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Password Checker
- // Date: 10.12.19
- #include<stdio.h>
- #include<ctype.h>
- // ctype.h header file is used to use all the test functions
- int main(){
- printf("=====Welcome To Password Checker=====\n\n");
- char password[20];
- printf("Enter your password: ");
- gets(password);
- int strength = 0, length = 0, i;
- int capital = 0, small = 0, special = 0, number = 0;
- for(i = 0; password[i] != '\0'; i++){
- // Check if character is lowercase
- if(islower(password[i])){
- small = 1;
- }
- // Check if character is uppercase
- else if(isupper(password[i])){
- capital = 1;
- }
- // Check if character is number
- else if(isdigit(password[i])){
- number = 1;
- }
- // Check if character is any special character
- else if(ispunct(password[i])){
- special = 1;
- }
- length++;
- }
- if(capital) strength++;
- if(small) strength++;
- if(special) strength++;
- if(number) strength++;
- if(length >= 8) strength++;
- if(strength <= 3) printf("\nPassword is weak.\n");
- else if(strength == 4) printf("\nPassword is medium.\n");
- else if(strength == 5) printf("\nPassword is strong.\n");
- }
- // Do a little bit of research on it.
- // Still not clear then ask.
- // Try not to memorize but to understand.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement