daily pastebin goal
40%
SHARE
TWEET

Untitled

a guest Mar 22nd, 2019 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int isSafePassword(char password[])
  2. {
  3.     int digits, mixed, SAFE=0, lenght;
  4.     passwordIsLongEnough(password, &lenght);
  5.     passwordContainsDigit(password, &digits);
  6.     passwordHasMixedCase(password, &mixed);
  7.  
  8.     if (lenght == 1 && digits == 1 && mixed == 1)
  9.     {
  10.         SAFE=0;
  11.         printf("This password is safe!");
  12.     }
  13.     else
  14.     {
  15.    
  16.         printf("Your password is not safe!");
  17.  
  18.         if (lenght == 0)
  19.         {
  20.             printf("\nYou need to have at least 8 character!");
  21.             SAFE++;
  22.         }
  23.         if (digits == 0)
  24.         {
  25.             SAFE++;
  26.             printf("\nYou need to have at least one digit!");
  27.         }
  28.         if (mixed == 0)
  29.         {
  30.             SAFE++;
  31.             printf("\nYou need to have at least one small and one big letter!");
  32.         }
  33.     }
  34.     return SAFE;
  35. }
  36.  
  37. struct account
  38. {
  39.     char name[30];
  40.     char password[30];
  41.     char newpassword[30];
  42.     int SAFE;
  43.     char phone[30];
  44. };
  45.  
  46. struct account EnterAccount(void)
  47. {
  48.     struct account person;
  49.     printf("\n\nEnter your username:");
  50.     scanf("%s", person.name);
  51.  
  52.     printf("Enter youe phone number");
  53.     scanf("%s", &person.phone);
  54.    
  55.     do
  56.     {
  57.         do
  58.         {
  59.             printf("\nEnter password:");
  60.             scanf("%s", person.password);
  61.             person.SAFE = isSafePassword(person.password);
  62.             if (person.SAFE > 0)
  63.             {
  64.                 printf("\ndu har %d fel", person.SAFE);
  65.             }
  66.         } while (person.SAFE >0);
  67.  
  68.         printf("\nEnter the same password");
  69.         scanf("%s", person.newpassword);
  70.  
  71.         if (strcmp(person.password, person.newpassword) != 0)
  72.         {
  73.             printf("The passwords are not matching!");
  74.         }
  75.         else
  76.         {
  77.             printf("Your account is accepted!");
  78.         }
  79.     }while (strcmp(person.password, person.newpassword) != 0);
  80.  
  81.     return person;
  82. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top