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.
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.
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.
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:
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.