Search for question
Question

Background

In reality, hackers learn more (password, hash) pairs as they continue to attack, so the dictionary has to

be expandable. Also, the hackers do not wish to do a linear search, i.e. scan the whole dictionary to find

the corresponding password for the given hash, so the dictionary needs to be sorted so that the

hackers can use a binary search.

Requirements

1. You will write a C program called project02 to help build a sorted dictionary file.

2. You must provide a Makefile

3. Your program will build a sorted dictionary as follows:

1. Use the following struct entry to store a (password, hash) pair.

struct entry {

char password [MAX_PASSWORD + 1];

char hash [DIG_STR_LEN + 1];

struct entry *next;

} entry;

2. Passwords are stored in a file given in argv [1], and the number of passwords in this file is

unknown. In the password file, one password is stored in one line. For every password in the

file, create (password, its sha256 hash), (133t version of the password, its sha256 hash), (plus1

version of the password, its sha256 hash) pairs and add these 3 pairs as 3 nodes to a linked

list.

3. The linked list must be sorted in the ascending order by the hash value. If the given

(password, hash) pair exists in the linked list already, do not insert.

4. You should sort the list as you insert items. You must implement sorting yourself, i.e. do not

use any sort functions provided in a library, e.g. C qsort()

5. Store the sorted linked list in the file given by argv [2]. The first line of this file should be the

number of pairs in the file. The subsequent lines would contain one (hash, password) pair per

line, with a comma in between.

4. Given "-v" (verbose) option, display how the linked list changes as shown in the Example Output.

Given

1. You will see a single-linked list demo and discuss Insertion Sort in class.

2. You may use any code from project01 and lab03. To copy files from one directory to another, see

shell basics.

Fig: 1