The following are the requirements for the password server client program named pass.cpp:

Similar documents
For a printable form of this assignment: assignment3.pdf. Assignment 3: Binary trees

ASSIGNMENT 5 Objects, Files, and a Music Player

ASSIGNMENT 5 Data Structures, Files, Exceptions, and To-Do Lists

COP4530 Data Structures, Algorithms and Generic Programming Recitation 3 Date: January 20 & 22, 2009

Jim Lambers ENERGY 211 / CME 211 Autumn Quarter Programming Project 2

Oregon State University School of Electrical Engineering and Computer Science. CS 261 Recitation 1. Spring 2011

3.Constructors and Destructors. Develop cpp program to implement constructor and destructor.

Protection Levels and Constructors The 'const' Keyword

Arrays. Comp Sci 1570 Introduction to C++ Array basics. arrays. Arrays as parameters to functions. Sorting arrays. Random stuff

CpSc 1111 Lab 9 2-D Arrays

CpSc 1011 Lab 5 Conditional Statements, Loops, ASCII code, and Redirecting Input Characters and Hurricanes

ASSIGNMENT 5 Objects, Files, and More Garage Management

Fall CSEE W4119 Computer Networks Programming Assignment 1 - Simple Online Bidding System

Assignment 3: Inheritance

Assignment 2: Temperature Class

Final assignment: Hash map

EECE.2160: ECE Application Programming

Cpt S 122 Data Structures. Introduction to C++ Part II

Constructors for classes

Lab 1 Introduction to UNIX and C

Data Management, Spring 2015: Project #1

CS 101, Spring 2014 April 1st Exam 2 Question 1. [3 points] What output is printed by the following code?

Assignment 5: MyString COP3330 Fall 2017

Hands on Assignment 1

Effective Programming in C and UNIX Lab 6 Image Manipulation with BMP Images Due Date: Sunday April 3rd, 2011 by 11:59pm

Linux Tutorial #1. Introduction. Login to a remote Linux machine. Using vim to create and edit C++ programs

King Abdulaziz University Faculty of Computing and Information Technology Computer Science Department

Constructors.

// class variable that gives the path where my text files are public static final String path = "C:\\java\\sampledir\\PS10"

COMP 250. Lecture 27. hashing. Nov. 10, 2017

Compilers Project 3: Semantic Analyzer

EECS 560 Lab 8: Leftist Heap as Priority Queue

ECE 244 Programming Fundamentals Fall Lab Assignment #5: Binary Search Trees

CS 135: Fall Project 2 Simple Cryptography

Question 1. [5 points] Consider the following partially-complete program, which begins on the left and continues on the right: HERE

CpSc 1111 Lab 6 Conditional Statements, Loops, the Math Library, and Random Numbers What s the Point?

Assignment 3: Distance COP3330 Fall 2017

Programming Assignment #4

CSC 210, Exam Two Section February 1999

1.00/1.001 Introduction to Computers and Engineering Problem Solving Fall 2002

ASSIGNMENT 2. COMP-202A, Fall 2011, All Sections. Due: Monday, October 17th, 2011 (23:30)

During the first 2 weeks of class, all students in the course will take an in-lab programming exam. This is the Exam in Programming Proficiency.

Project 2: Buffer Manager

CpSc 1111 Lab 5 Formatting and Flow Control

OPERATING SYSTEMS ASSIGNMENT 4 FILE SYSTEM

Parallel Programming Pre-Assignment. Setting up the Software Environment

CS447-Network and Data Communication Project #2 Specification, Fall 2017 Due December 5, 2017

CpSc 1011 Lab 3 Integer Variables, Mathematical Operations, & Redirection

CpSc 1011 Lab 4 Formatting and Flow Control Windchill Temps

Lab 03 - x86-64: atoi

Write code that simulates one roll of a 6-sided die and prints out the

Project #1 rev 2 Computer Science 2334 Fall 2013 This project is individual work. Each student must complete this assignment independently.

EECE.4810/EECE.5730: Operating Systems Spring 2018 Programming Project 3 Due 11:59 PM, Wednesday, 4/18/18 Monday, 4/30/18

CS 215 Fundamentals of Programming II Spring 2011 Project 2

PIC 10B Lecture 1 Winter 2014 Homework Assignment #3

Week 8: Operator overloading

ASSIGNMENT 4 Records and Objects

Do not write in this area EC TOTAL. Maximum possible points:

We first learn one useful option of gcc. Copy the following C source file to your

Systems Programming/ C and UNIX

University of Maryland Baltimore County. CMSC 202 Computer Science II. Fall Mid-Term Exam. Sections

Homework 1 - Extracting Data from a CSV file

EECS 560 Lab 6: Min 3-Heap and Performance Analysis of Operations

Jim Lambers ENERGY 211 / CME 211 Autumn Quarter Programming Project 4

ESS Security Enhancements

CS 211 Programming Practicum Spring 2018

15213 Recitation Section C

Project 5 Handling Bit Arrays and Pointers in C

Fall CSEE W4119 Computer Networks Programming Assignment 1 - Simple Chat Application

COMP 321: Introduction to Computer Systems

Attend to details of the value iteration and policy iteration algorithms Reflect on Markov decision process behavior Reinforce C programming skills

Project 1: Implementing a Shell

CS 1653: Applied Cryptography and Network Security Fall Term Project, Phase 2

ASSIGNMENT 4 Classes and Objects

CpSc 1111 Lab 4 Part a Flow Control, Branching, and Formatting

file:///home/baker/dept/ugcc/smalcs08/cop3330/cop3330_f2007pc_as... Project 1: Tracker

CS 101, Spring 2016 March 22nd Exam 2

CS 211 Programming Practicum Fall 2018

University of Toronto

COP Programming Assignment #7

CS101 Homework 4: Social Network

ENERGY 211 / CME 211. Functions

Programming Assignment 5 (100 Points) START EARLY!

Programming Assignment #4 Arrays and Pointers

New York University Computer Science Department Courant Institute of Mathematical Sciences

CE221 Programming in C++ Part 1 Introduction

Project 3: Base64 Content-Transfer-Encoding

CS1622. Semantic Analysis. The Compiler So Far. Lecture 15 Semantic Analysis. How to build symbol tables How to use them to find

Course "Data Processing" Name: Master-1: Nuclear Energy Session /2018 Examen - Part A Page 1

CS Operating Systems, Fall 2018 Project #0 Description

OO Fortran Exercises

CPE 112 Spring 2015 Exam II (100 pts) March 4, Definition Matching (8 Points)

CDA3101 Project 1: MIPS Assembler Due 2/5. I. Purpose

gcc o driver std=c99 -Wall driver.c bigmesa.c

Advanced Systems Programming

CS Fundamentals of Programming II Fall Very Basic UNIX

Fundamentals of Programming Session 13

Operator overloading

CHAPTER 4 FUNCTIONS. 4.1 Introduction

ASSIGNMENT 3 Classes, Objects and the Robot World

Transcription:

COP 4530/CGS5425: Data Structures, Algorithms, and Generic Programming Florida State University, Dept. of Comp. Sci., Fall 2006 Instructor: Breno de Medeiros TA: Ling Toh Assignment 4: HashTables Goals: In this assignment, you will be required to implement a program to simulate a simple password server. The data structure for the password server is a HashTable object. You are required to write the program for both the password server client program, as well as the HashTable class. Requirements for Client Program The following are the requirements for the password server client program named pass.cpp: The client must store username and encrypted password pairs in a HashTable object. The client must allow the user to: 1. Load the password file into the HashTable object. The client reads the username and encrypted password as a pair object from a file and adds the pair entry into the HashTable object. 2. Add a new username and password. The client reads in the username and password as a pair object from the user entry and adds the pair entry into the HashTable object. 3. Remove an existing user. The client reads in the username from the user and removes the corresponding pair entry from the HashTable object. 4. Change an existing user s password. The client reads in the username and password as a pair object, the new password from the user and modifies the pair object s second entry in the HashTable object. 5. Check if a user exists. The client reads in the username and password as a pair object from the user and checks if the pair entry exists in the HashTable object. 6. See the structure and contents of the HashTable to screen. 7. Obtain the size of the HashTable. 8. Save the username and password combination to a file. 9. Exit the client. The client exits the program. The client must re-prompt the user for the next choice from the menu and exit the program only when the user selects the exit x option.

You MUST use the code provided in the attached pass.cpp file as a standardized option menu to develop the implementation for the rest of the client. You may not alter the Menu() method. Requirements for HashTable class A partial interface and implementation of the HashTable class is provided in the attached hashtable.h and hashtable.cpp files. The underlying HashTable data structure is a vector of lists, with each list storing pair objects. Hence, the data structure would be declared as, vector< list < pair < string, string > > > bucketvector; The partially distributed HashTable files contain the following functionality: unsigned int Index (const string & str): Returns the index of the bucketvector where the string str is hashed into. str stores the username. unsigned int hash_function (const string& str): Returns an integer value where the string str is hashed. str stores the username. This method is called by the Index method. unsigned int prime_below(unsigned int n): Returns the highest prime number below n. This method is called by the 1-parameter constructor. void setprimes(vector<unsigned int> &v): Evaluates the index value of a vector object and sets the corresponding element to store the value 1 if the index was a prime number and 0 if the index was not a prime number. This method is called by the prime_below method. Note: The vector object used in this method is used solely for the purpose of obtaining the highest prime number below n and is not the same vector object representing the HashTable. In addition, your full implementation MUST AT LEAST provide the following functionality: HashTable(): no-argument constructor. Initializes the vector to a default capacity of 11. We use a prime number to enhance the quality of the hashing performed later. We shall refer to the resulting capacity as 11 buckets. HashTable(size_t n): 1-parameter constructor. Initializes the vector to a specified capacity. This constructor is called by the client to set the capacity of the underlying vector to the highest prime number below n.

~HashTable():destructor. Iterates through the vector and clears all the lists within each bucket. Method that loads entries from a file: This method should read the username and password entry from a file and add the entries into the HashTable. Each pair entry is separated by a carriage return. A line entry is represented in the format: username:encrypted_password For example, a sample entry file is as follows: hemmi:i5ltky7/qq.yhp1hhzrcy/ marge:qnr/8wr64nvx3qquy.q7u1 hank:djp.joxf9u3vudm8qunmy/ toh:czz4fml29pz0vlpvacr1.0 sean:x.pthyv62/iu9ecwrgkbv0 stuart:sn0akstpbrrfpeppk4qpi/ matthew:cja3fxuld9/nilbzok1pr0 kelly:rixhnhgre6ouzda1o/lvz. Method that adds a user: This method should take the pair object containing the username and encrypted password and add the entry into the HashTable only if the username does not exist in the HashTable. A password MUST be encrypted before storage. For this project, we shall use the GNU C Library s crypt() method to encrypt the password. The algorithm for the crypt() method shall be MD5-based. The salt shall be the character stream $1$########. The resulting encrypted character stream is the $1$######## + $ + 22 characters = 34 characters in total. A user password is the sub string containing the last 22 characters, located after the 3 rd $. Note: A sample program to demonstrate the use of the crypt() method will be provided during Recitation 10. Method that removes a user: This method should find the username from the HashTable and remove the pair entry from the HashTable. Method that changes a username s password: This method should find the pair object containing the username and encrypted password and modify the pair s second entry in the HashTable with the new password. Method that find s a username: This method should inform the user if the username and encrypted password pair entry exists in the HashTable. Method that prints HashTable s contents: This method should print the structure and contents of the HashTable to the screen.

Method that returns the size: This method should return the size of the HashTable. Method that writes entries to a file: This method should write the username and password entries in the HashTable to a file. Each entry is separated by a carriage return. A line entry is represented in the format: username:encrypted_password For example, a sample entry output file is as follows: hemmi:i5ltky7/qq.yhp1hhzrcy/ marge:qnr/8wr64nvx3qquy.q7u1 hank:djp.joxf9u3vudm8qunmy/ toh:czz4fml29pz0vlpvacr1.0 sean:x.pthyv62/iu9ecwrgkbv0 stuart:sn0akstpbrrfpeppk4qpi/ matthew:cja3fxuld9/nilbzok1pr0 kelly:rixhnhgre6ouzda1o/lvz. Extra-credit ( 5 points) You may submit an alternative version to your client named spass.cpp, in which the client hides the user s entries whenever the user keys in a password or new password. Download Instructions To download the partial/sample files, go into the directory where you wish to have the assignment files copied to, and type the command line: cp -r ~cop4530/fall06/partials/proj4/. The following files have been provided for you: 1. hashtable.h : partial implementation 2. hashtable.cpp : partial implementation 3. lpass.x : sample executable for linprog.cs.fsu.edu 4. lspass.x: sample executable with hidden password entries for linprog.cs.fsu.edu 5. ppass.x : sample executable for program.cs.fsu.edu 6. pspass.x: sample executable with hidden password entries for program.cs.fsu.edu 7. test1: sample test case. Deliverables 1. Your implementation must be entirely contained in the following files, which MUST be named,

a. hashtable.h b. hashtable.cpp c. pass.cpp d. spass.cpp (optional: extra-credit) e. makefile 2. Your program must compile on linprog.cs.fsu.edu or program.cs.fsu.edu. If you program does not compile on either machines, the grader cannot test your submission. 3. Your executable(s) must be named pass.x and spass.x (for extra-credit option). 4. The interaction and output (including error messages) of your client s executable(s) must behave in the same manner as the distributed ppass.x and pspass.x (for program.cs.fsu.edu) or lpass.x and lspass.x (for linprog.cs.fsu.edu). e.g. One of the ways to test your program would be to run a diff command between the output file(s) created by your executable(s) and the output file(s) created by the distributed executable(s). Points will be deducted for not complying with these requirements. For instructions on how to submit your project, consult the first assignment, which is posted online. Remember to substitute "4" for "1" in all the command and path names which have the form "projectx" or "projx