Comp 122 Lab 7 Lab Report and Source Code

Submitted by: Submitted by

Views: 10

Words: 1461

Pages: 6

Category: Other Topics

Date Submitted: 11/19/2015 10:09 PM

Report This Essay

COMP 122 Lab 7 Lab Report and Source Code

Purchase here

http://devrycourse.com/COMP%20122/comp-122-lab-7-lab-report-and-source-code

Product Description

The focus of this lab is on using strings. You will have an opportunity to work with

both C style strings and the string data type. This lab also gives you an opportunity to

use what you have learned previously, including using functions, array processing,

repetition, and selection. You will also have an opportunity to work with file input and output.

You are to design and implement a program which does encryption and decryption of data from

files. Encryption is the process of taking plain lines of text and performing some algorithmic

transformation on the data to create an encrypted line of text which looks nothing like the original.

Decryption is the process of taking an encrypted line of text and performing some algorithmic

transformation on the data to recover the original line of plain text.

Encryption and Decryption Approach

Our approach to encryption and decryption involves two strings.

The first is an encryption / decryption string which we will allow to be up to 128 lower case alphabetical characters

in length. The second string is a line of text from a file that is to be encrypted or decrypted.

Our basic strategy for encrypting data is based on mapping alphabetical characters to specific values,

then doing some simple mathematical operations to create a new value. First of all, every character

in either the encryption string or the input string is mapped to a number between 0 and 25 based on its position in the alphabet.

= 0

= 1

= 25

The mapped value of a character is easily obtained by doing the following:

For lower case characters, subtract 'a' from the character.

For upper case characters, subtract 'A' from the character.

To calculate the modified value of the first character of input we add its mapped value to the

mapped value from the first character...