Description

Write a C program, called password_check.c, that reads a list of potential passwords from a file, determines for each of them whether any of the six rules above is violated, and outputs the results to another file. The details of the input and output file formats are described below.

Input

The program should read its input from the file passwords. dat that consists of one or more potential passwords, one per line, followed by a line containing only the word END. Each potential password consists of at least two and at most 42 characters, and may contain any characters except whitespace. Here is a sample input file:

Chuck Norr!s
Bruc3;-)
$chn3!3r
APp13
N!k3
@d!das
R33b0k
END

You do not need to check the validity of the input file: you can assume that it conforms to the specifications detailed above. You can also assume that the input file contains at least 2 and at most 256 lines.

Output

The program should write its output to the file passwords.out. For each password, output whether or not it is acceptable. If it is not acceptable, indicate all the rules that it violates in ascending order. Here is a sample file passwords.out which results upon processing the input file above:

Chuck Norr!s is not acceptable. Rules 4,6 violated.
Bruc3;-) is not acceptable. Rule 3 violated.
$chn3!3r is not acceptable. Rule 6 violated.
APp13 is not acceptable. Rule 6 violated.
N!k3 is not acceptable. Rule 1 violated.
@d!das is not acceptable. Rule 2 violated.
R33b0k is acceptable.

Rules

Rule 1: It should be a string that is at least 5 characters long.

Rule 2: It should contain characters from at least three of the following four groups:

  • the 26 lowercase letters a, b, . . ., z
  • the 26 uppercase letters A, B, . . ., Z
  • the 10 digits 0, 1, . . .., 9
  • the 6 non-alphanumeric characters !,@, #. $, &, and *

Note that this is similar to the password guidelines published by UC San Diego. See https://blink.ucsd.edu/technology/network/access/secure-passwords.html.

Rule 3: It should not contain any characters other than the 68 characters listed in Rule 2.

Rule 4: It should not contain two consecutive occurrences of the same character, except for ee, EE, 33 or oo, OO, 00.

Rule 5: It must contain at least two vowels, not necessarily distinct. The English language vowels are a, e, i, o, u and their uppercase versions A, E, I, O, U. But for the purpose of creating a password, the digits 0, 1, 3 (potential substitutes for O, I, E, respectively) and the non-alphanumeric characters !, @ are also considered vowels. Thus

a, e, i, o, u, A, E, I, O, U, 0, 1, 3, !, @

is the full list of the 15 characters that are considered to be vowels. The other 53 allowable characters are considered to be non-vowels.

Rule 6: It should not contain three consecutive vowels or three consecutive non-vowels. Anything not on the list of 68 allowable characters is neither a vowel nor a non-vowel.

Notes

  • You should implement each of the six rules as a separate function. This is required, and it would also make your life easier.
  • You can use any functions you like from the C standard library. The header file < stdio.h> is already included in exam_template.c. If you would like to use standard library functions other than those declared in < stdio.h>, you should #include the corresponding header files.
  • Try to make your code easy to follow and understand: choose meaningful names for identifiers, use proper indentation, and provide comments wherever they are useful. While this is not required, it could help you receive partial credit: source code that is not correct and is also difficult to understand will receive zero credit, even if it is partially correct.

Hints

  • Since the potential passwords in the input file do not contain whitespace, they can be read using the fscanf standard library function with the $s conversion specification.
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.