Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int isSafePassword(char password[])
- {
- int digits, mixed, SAFE=0, lenght;
- passwordIsLongEnough(password, &lenght);
- passwordContainsDigit(password, &digits);
- passwordHasMixedCase(password, &mixed);
- if (lenght == 1 && digits == 1 && mixed == 1)
- {
- SAFE=0;
- printf("This password is safe!");
- }
- else
- {
- printf("Your password is not safe!");
- if (lenght == 0)
- {
- printf("\nYou need to have at least 8 character!");
- SAFE++;
- }
- if (digits == 0)
- {
- SAFE++;
- printf("\nYou need to have at least one digit!");
- }
- if (mixed == 0)
- {
- SAFE++;
- printf("\nYou need to have at least one small and one big letter!");
- }
- }
- return SAFE;
- }
- struct account
- {
- char name[30];
- char password[30];
- char newpassword[30];
- int SAFE;
- char phone[30];
- };
- struct account EnterAccount(void)
- {
- struct account person;
- printf("\n\nEnter your username:");
- scanf("%s", person.name);
- printf("Enter youe phone number");
- scanf("%s", &person.phone);
- do
- {
- do
- {
- printf("\nEnter password:");
- scanf("%s", person.password);
- person.SAFE = isSafePassword(person.password);
- if (person.SAFE > 0)
- {
- printf("\ndu har %d fel", person.SAFE);
- }
- } while (person.SAFE >0);
- printf("\nEnter the same password");
- scanf("%s", person.newpassword);
- if (strcmp(person.password, person.newpassword) != 0)
- {
- printf("The passwords are not matching!");
- }
- else
- {
- printf("Your account is accepted!");
- }
- }while (strcmp(person.password, person.newpassword) != 0);
- return person;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement