CS2023 Assignment 6

Winter 2004

Due Friday, March 12, 10:30 AM, in the assignment bin on E-Level, and electronically via the "Submit your assignment" link on the CS2023 home page. This assignment will be marked out of 50 points.

Password Checker

Choosing a good password is vital in order maintain the security and integrity of the computer systems you use. A good password is one that is hard for others to guess. The guidelines for a good password vary, but they may include the following: use at least 6 characters, at least one of which should be a non-alphabetic character, but with a minimum of two alphabetic characters, and the password should not be found in the dictionary. These guidelines are by no means sufficient in practice, but they will suffice for this assignment.This assignment will give you some practice in manipulating individual strings and arrays of strings.

Requirements

Write a program, called password_check.c, that prompts the user for a possible password, and evaluates it according to the following rules.
The password must:
  1. not contain spaces
  2. have at least 6 characters
  3. have at least two alphabetic characters
  4. have at least one non-alphabetic character
  5. must not match a word in the Linux dictionary (/usr/share/dict/words)
A message must be printed for each rule that the user's password breaks. The program must keep prompting for a new password, until one is entered that follows all the above rules, or until the user enters ctrl-d (EOF). Here is a sample session:
$ ./password_check
fred
Password must be at least 6 characters long
Password must contain at least one non-alphabetic character
Try again..
fred a
Password may not contain spaces
Try again..
3456
Password must be at least 6 characters long
Password must contain at least two alphabetic characters
Try again..
modular
Password must contain at least one non-alphabetic character
Password in dictionary
Try again..
home-brew
Password in dictionary
Try again..
ftvft!!
Password OK
$
Your program must include the following two functions (of course, you are free to create others as well):
char **dictRead(char *fname, int max)
Reads at most max words from file fname, which contains a single word per line, and stores them in a dynamically allocated array of strings, and finally returns the address of this array. This function must not use more space than is necessary to store each word (for example, "word" would only require a block of 5 characters)

int findWord(char **dict, char *word)
Searches the array of strings dict for an exact match with word, and returns 1 if a match is found, and 0 otherwise.

Marking Scheme

Make sure you follow the C Language Coding Standard, format your code clearly, and choose meaningful variable names: these are all worth 8 marks. The remaining marks will be assigned for correct output (as in the above example), implementation of the rules for a good password that follows the above requirements, and implementation of the dictRead and findWord functions as required.

Deliverables

A hardcopy of your assignment in the bin on E-level, which must include source code of your program and electronic submission of the program, which must be called password_check.c  (lower case only!) to the "Submit your assignment" link on the CS2023 home page.
 
 
 
Eric Aubanel, Feb. 27 2004