Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int validatePwd(char * password)
- {
- char symbol[4] = { 33, 35, 63, 64 };
- char numbers[10] = { 48, 49, 50, 51, 52, 53, 54, 55, 56, 57 };
- char bigAZ[26] = { 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90 };
- char smallAZ[26] = { 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122 };
- int length, criteriaLength, criteriaSymb = 0, criteriaNr = 0, criteriaBig = 0, criteriaSmall = 0;
- length = strlen(password);
- if (length >= 8)
- {
- criteriaLength = 1;
- for (int i = 0; i < length; i++)
- if (password[i] == 33 || password[i] == 35 || password[i] == 63 || password[i] == 64)
- {
- criteriaSymb = 1;
- }
- else
- criteriaSymb = 0;
- for (int i = 0; i < length; i++)
- if (password[i] >= 48 && password[i] <= 57)
- {
- criteriaNr = 1;
- }
- else
- criteriaNr = 0;
- for (int i = 0; i < length; i++)
- if (password[i] >= 65 && password[i] <= 90)
- {
- criteriaBig = 1;
- }
- else
- criteriaBig = 0;
- for (int i = 0; i < length; i++)
- if (password[i] >= 97 && password[i] <= 122)
- {
- criteriaSmall = 1;
- }
- else
- criteriaSmall = 0;
- }
- else
- {
- criteriaLength = 0;
- }
- if (criteriaLength == 1 && criteriaSymb == 1 && criteriaNr == 1 && criteriaBig == 1 && criteriaSmall == 1)
- {
- printf("\nValid password");
- return 1;
- }
- else
- {
- printf("\nInvalid password");
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement