60-141 Introduction to Programming II Winter, 2014 Assignment 2

Similar documents
ASCII Encoding. The char Type. Manipulating Characters. Manipulating Characters

CISC 181 Project 3 Designing Classes for Bank Accounts

Decision Logic: if, if else, switch, Boolean conditions and variables

CS 241 Data Organization Coding Standards

Illustration 1: Diagram of program function and data flow

CP Lab 2: Writing programs for simple arithmetic problems

Sources: On the Web: Slides will be available on:

El Dorado Union High School District Educational Services

Informatica e Sistemi in Tempo Reale

CS 1340 Sec. A Time: 8:00AM, Location: Nevins Instructor: Dr. R. Paul Mihail, 2119 Nevins Hall, rpmihail@valdosta.

Business Administration Online Course - Plagiarism and Fraud

Lecture 25 Systems Programming Process Control

Chapter 3. Input and output. 3.1 The System class

CS 261 C and Assembly Language Programming. Course Syllabus

Langara College: Criminal Justice Department. Fall Criminal Justice 1115 (02): Introduction to the Criminal Justice System

CSCI 1301: Introduction to Computing and Programming Summer 2015 Project 1: Credit Card Pay Off

CS 300 Data Structures Syllabus - Fall 2014

How To Port A Program To Dynamic C (C) (C-Based) (Program) (For A Non Portable Program) (Un Portable) (Permanent) (Non Portable) C-Based (Programs) (Powerpoint)

Comp151. Definitions & Declarations

How To Be A Responsible Student

CPSC 226 Lab Nine Fall 2015

WILLIAM PATERSON UNIVERSITY Department of English ENG 2070: Effective Business Writing Winter Semester: December 22, 2014 January 11, 2014

/* File: blkcopy.c. size_t n

5 Arrays and Pointers

Introduction to Computer Programming (CS 1323) Project 9

So far we have considered only numeric processing, i.e. processing of numeric data represented

System Calls Related to File Manipulation

Lecture 3. Arrays. Name of array. c[0] c[1] c[2] c[3] c[4] c[5] c[6] c[7] c[8] c[9] c[10] c[11] Position number of the element within array c

SQLITE C/C++ TUTORIAL

FACULTY of MANAGEMENT MARKETING MGT 2020 Z Fall 2015

Business Ethics (BUS 105) Cycle II, Spring, 2012 Semester

Basics of I/O Streams and File I/O

Project #2: Secure System Due: Tues, November 29 th in class

Channel Access Client Programming. Andrew Johnson Computer Scientist, AES-SSG

8.5. <summary> Cppcheck addons Using Cppcheck addons Where to find some Cppcheck addons

DEPARTMENT OF SUPPLY CHAIN MANAGEMENT I.H. ASPER SCHOOL OF BUSINESS UNIVERSITY OF MANITOBA SCM2230: INTRODUCTION TO SUPPLY CHAIN MANAGEMENT

Lab 4: Socket Programming: netcat part

Programming Autodesk PLM 360 Using REST. Doug Redmond Software Engineer, Autodesk

COSC Introduction to Computer Science I Section A, Summer Question Out of Mark A Total 16. B-1 7 B-2 4 B-3 4 B-4 4 B Total 19

CMSC Fundamentals of Computer Programming II (C++)

Langara College: Criminal Justice Department. Fall Criminal Justice 1213: Women and the Justice System

TFTP Usage and Design. Diskless Workstation Booting 1. TFTP Usage and Design (cont.) CSCE 515: Computer Network Programming TFTP + Errors

BRAZOSPORT COLLEGE LAKE JACKSON, TEXAS SYLLABUS ITSE 1432 INTRODUCTION TO VISUAL BASIC.NET PROGRAMMING

Encryption Recipient Guidelines

Dalhousie University CSCI 2132 Software Development Winter 2015 Lab 7, March 11

CS170 Lab 11 Abstract Data Types & Objects

COS 480/580: Database Management Systems

SI 539, Winter 2014 Complex Web Design

C++ Programming Language

GET 114 Computer Programming Course Outline. Contact: Office Hours: TBD (or by appointment)

COURSE TEXTBOOK [Insert required course text academic format for book listing with ISBN# and edition]

ECE 122. Engineering Problem Solving with Java

Philadelphia University Faculty of Information Technology Department of Computer Science --- Semester, 2007/2008. Course Syllabus

3.5. cmsg Developer s Guide. Data Acquisition Group JEFFERSON LAB. Version

PSYO1032 Syllabus Online Course Introduction to Psychology and Neuroscience II: From Social Interaction to Psychopathology

Output: struct treenode{ int data; struct treenode *left, *right; } struct treenode *tree_ptr;

COMP252: Systems Administration and Networking Online SYLLABUS COURSE DESCRIPTION OBJECTIVES

CS A250 (CRN ) C++ Programming Language 2. Syllabus Fall 2015

Molecular Dynamics Simulations with Applications in Soft Matter Handout 7 Memory Diagram of a Struct

PHOENIX COLLEGE ONLINE. SBS220 Internet Marketing for Small Business

Virtuozzo Virtualization SDK

As previously noted, a byte can contain a numeric value in the range Computers don't understand Latin, Cyrillic, Hindi, Arabic character sets!

Course Content Concepts

Brazosport College Syllabus for Criminology (CJSA 1325) Spring 2014 (Online)

(b) slack file space.

The C Programming Language course syllabus associate level

Storage Classes CS 110B - Rule Storage Classes Page 18-1 \handouts\storclas

The Payroll Program. Payroll

NURS 1050 Medical Terminology. Course Description

Introduction to Organizational Behavior (Business 260)

Project 2: Bejeweled

El Dorado Union High School District Educational Services

DEPARTMENT OF SUPPLY CHAIN MANAGEMENT I.H. ASPER SCHOOL OF BUSINESS UNIVERSITY OF MANITOBA SCM2230: INTRODUCTION TO SUPPLY CHAIN MANAGEMENT

RARITAN VALLEY COMMUNITY COLLEGE ACADEMIC COURSE OUTLINE CISY 233 INTRODUCTION TO PHP

SYLLABUS. BOOK AUTHOR ED YEAR PUBLISHER ISBN# REVIEW Managing Human Resources

Unit Testing & JUnit

Lab 5 Introduction to Java Scripts

Psychology 1031 Syllabus Online Course Introduction to Psychology and Neuroscience I: From Neuron to Person

CS 2112 Spring Instructions. Assignment 3 Data Structures and Web Filtering. 0.1 Grading. 0.2 Partners. 0.3 Restrictions

It has a parameter list Account(String n, double b) in the creation of an instance of this class.

Division of Fine Arts Department of Photography Course Syllabus

VESALIUS COLLEGE Brussels, Belgium. BUS 211 Human Resource Management

COMPUTER SCIENCE TECHNOLOGY ITSC 1301 INTRODUCTION TO COMPUTERS Website: Course Syllabus

Business Administration

File class in Java. Scanner reminder. Files 10/19/2012. File Input and Output (Savitch, Chapter 10)

COURSE APPROVAL DOCUMENT Southeast Missouri State University

CLARENDON COLLEGE DIVISION OF LIBERAL ARTS FEDERAL GOVERNMENT 2305 ONLINE COURSE SYLLABUS 3 CREDIT HOURS

ISM 4113: SYSTEMS ANALYSIS & DESIGN

Business Administration

Online Sections of CIS101, CIS141 & CIS240 About This Course and Getting Started Online Instructor Brad Ford

Introduction to Java Applications Pearson Education, Inc. All rights reserved.

Transcription:

60-141 Introduction to Programming II Winter, 2014 Assignment 2 Array In this assignment you will implement an encryption and a corresponding decryption algorithm which involves only random shuffling of the input data. The process is explained in the following diagram. Try to figure out the relationship between the Input data, the key and the output (encrypted) data. The following table may be handy. The decryption process just does the opposite of the encryption process, which is to restore the original content. Index Input String Key Encrypted String Index 0 H 3 l 0 1 e 2 o 1 2 l 4 e 2 3 l 0 H 3 4 o 1 l 4 A skeleton program is provided for you with prototypes of the required functions and some function calls that you may not be familiar with, yet. Read the instructions in the program and build your solution around it (call it Assign2.c). You must implement all the unimplemented functions without altering their prototypes and some statements in the main, (look for the flag TODO). You are NOT allowed to include any additional header file(s). A box below the skeleton program contains the output from a sample run.

Contact your Instructor or GA s for any additional explanation you might need. REQUIREMENTS: - Write and document a complete C program that is capable of satisfying the requirements of this assignment problem. - UNDOCUMENTED OR IMPROPERLY DOCUMENTED code will automatically lose 50% marks. - PLAGIARIZED work will not be graded and receive a mark of ZERO and reported according to the Senate bylaws. - The question requires use of I/O redirection. Please review the textbook for an example on using I/O redirection from flat files. - TO SUBMIT: No later than the submission deadline, your email must be received by: cs14101@uwindsor.ca, late submissions are not accepted and will receive a mark of ZERO. - Email your work as an attachment, include both the source file (assign1.c) and the script file (assign1.txt) - see below how to create the script file. To create a script file (one that logs your compilation steps and your output in a text file): 1. script assign2.txt 2. cat assign2.c 3. cat input.txt 4. cc assign2.c 5. a.out < input.txt 6. ls -l 7. exit (DO NOT FORGET THIS STEP!!) Email both files with the mail Subject field format " Ass #2 section 51" (replacing 51 by your actual registered lab section number) to: cs141@courses.cs.uwindsor.ca NOTE: Submissions that are not received correctly by the deadline will automatically receive a ZERO mark. In the event that more than one email submission is sent, only the last one (according to the date and time stamp) will be marked. It is your responsibility to ensure the email attachment is sent correctly (readable) and to the right mailbox by the deadline. If you omit the email subject header or fail to follow the format provided above for the attachment file, your assignment may not be graded. Late assignment submissions are not accepted! NOTES: 1. Your assignment must be RECEIVED by the due date and time. Late assignment submissions are NOT accepted. Keep your script file, and all your code unmodified as proof of its completion in case it is not received. 2. It is your responsibility to get an early start on the assignment, research and ask questions ahead of time from the due date. 3. You must use your uwindsor email account to submit your work. Please do not use other email accounts (hotmail, yahoo etc...) for the purpose of assignment submissions.

4. Marks will be deducted for unclear code. (improper spacing and alignment, hard to read programs and missing outputs). 5. Make sure you turn in a complete script file that clearly shows: your code, your compilation process, a listing of the directory showing your source file(s) and the a.out with the date/time stamps, and the output. 6. PLAGIARISM: CHEATING IS NOT TOLERATED. You must submit your own work. Students who are suspected of copying someone else's work will be reported to the department's chair and the Dean of Science and be dealt with in accordance with the University policies. You should not share your code with others. Codes that are similar to each other will BOTH be reported as potential evidence of copying. It is imperative that you write your own code. 7. Authorized/limited help on this assignment may be provided directly from your Lecture or Lab instructors and Teaching Assistants.

/** Partially completed data encryption program Assign2.c **/ #include<stdio.h> #include<stdlib.h> #include<string.h> #include<time.h> #define SIZE 256 /** Function Prototypes **/ void generate_key( int array[], int size ); void encrypt_data( char out[], const char in[], const int key[], int size ); void decrypt_data( char out[], const char in[], const int key[], int size ); int main() { char inputstr[size]; char encrypt[size]; char decrypt[size]; int key[size]; int i, size; printf( "Enter a string to encrypt: " ); scanf( " %[^\n]s", inputstr ); // to scan a sentence from the keyboard size = strlen( inputstr ); // strlen is a library function defined in // string.h to find the length of a string printf( "Generating key...\n" ); generate_key( key, size ); // should randomly generate unique keys /** TODO: Print keys **/ printf( "Encrypting string...\n" ); encrypt_data( encrypt, inputstr, key, size ); // encrypt a string /** TODO: Print encrypted string **/ printf( "Decrypting string...\n" ); decrypt_data( decrypt, encrypt, key, size ); // decrypt a string /** TODO: Print decrypted string **/ return 0;

void generate_key( int array[], int size ){ srand( time( NULL ) ); /** TODO: Define function generate_key. REMEMBER: Each key (integer) MUST be unique! **/ void encrypt_data( char out[], const char in[], const int key[], int size ){ /** TODO: Define function encrypt_data **/ void decrypt_data( char out[], const char in[], const int key[], int size ){ /** TODO: Define function decrypt_data **/ /* END OF PROGRAM LISTING */ A Sample run of the program: $ gcc Assign2.c $ a.out Enter a string to encrypt: one ring to rule them all Generating key... Key = 18 6 17 19 23 21 3 0 9 12 7 8 11 22 4 14 16 1 15 2 24 10 13 5 20 Encrypting string... Encrypted string is "hntel otrg arl neelouim" Decrypting string... Decrypted string is "one ring to rule them all"