Advertisement
ggorann

Challenge #1 Buckys Room - Is password strong or weak

Oct 23rd, 2014
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.67 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <ctype.h>
  4. #include <string.h>
  5. #include <math.h>
  6.  
  7. /*
  8. Challenge #1 Buckys Room
  9. Is password strong or weak by Goran
  10. */
  11.  
  12. int main()
  13. {
  14.     int upperCase = 0, number = 0, dolarSign = 0, loop;
  15.     char password[20], temp; // 20 bytes for storing user password and char temp for storing one character for testing purpose.
  16.     printf("Please enter your password: "); // asking user to enter his password.
  17.     scanf(" %s", password); // gets input from user and stores it into char password.
  18.  
  19.     for(loop=0; loop<=20; loop++){ // loop that will start at 0, end at 20 and will increment by one.
  20.         temp = password[loop]; // storing one character from user password at a time in char temp for testing.
  21.         if(isupper(temp)){ // if character that we are testing is uppercase letter.
  22.             upperCase++; // increment upperCase integer by one if statement above is true.
  23.         }if(isdigit(temp)){ // if character that we are testing is number.
  24.             number++; // increment number integer by one if statement above is true.
  25.         }if(temp == '$'){ // if character that we are testing is dolar sign.
  26.             dolarSign++; // increment dolarSign integer by one if statement above is true.
  27.         }
  28.  
  29.     }if(upperCase >= 1 && number >= 1 && dolarSign >= 1){ // password need to have uppercase letter, number and dolar sign to be strong.
  30.         printf("Your password is strong. \n \n"); // if statement above is true it will print out user that password he entered is strong.
  31.     }else{
  32.         printf("Your password is weak. \n \n"); // else if statement above is not true it will print out user that password he entered is weak.
  33.         }
  34.  
  35.     system("pause"); // pausing program after executing.
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement