SlideShare a Scribd company logo
CS150 Assignment 7
Cryptography
Date assigned: Monday, November 23, 2015
Date Due: Tuesday, December 8, 2015, 9:40 am (40 points)
There is no late grace period for this last assignment!!!!!
Cryptography is an exciting area of Computer Science
concerned with hiding and protecting information.
This is the branch of Computer Science that allows you to send
your credit card securely to a web site or to
decrypt or encrypt secret messages.
For this project, you will be building a program that will take a
plain text file and produce an encrypted file
(or vice versa). The encryption scheme you need to implement
is inspired by the Enigma Machine, a
German encryption machine from WWII
(http://en.wikipedia.org/wiki/Enigma_machine). The Enigma
machine code was broken by Alan Turing and his team at
Bletchley Park during World War II.
Encryption Scheme:
Simple substitution
A simple substitution cipher (sometimes called a Caesar cipher)
maps each letter of the alphabet to another
letter of the alphabet as shown below:
To encrypt a letter, find the letter on the top and use the letter
below it as the encrypted output. Using the
above table, the encrypted output for C would be Z. To decrypt
a letter, find the letter on the bottom and
use the letter above it as the decrypted output.
To make things more interesting, a secret key is used to specify
how the input characters are mapped to
output characters. The key, which is a single character,
specifies which letter the output row starts on. The
key in the above example is X. (The input row always starts
with A).
N-Way Substitution
You will need to implement an N-Way substitution encryption
scheme. This means you will have N
substitution mappings. The character to be encrypted will be
used as the input to the first mapping; the
output of the first mapping will be the input to the second
mapping. The output of the second mapping will
be the input to the third mapping, etc. The output of the N-1
mapping is the input to the N mapping, and the
output of the N mapping is the encrypted character.
Each mapping has its own key, so you will have a total of N
secret keys for this scheme. The value N,
which is specified by the user, may be between 2 and 25.
You must use a single, multidimensional array to represent all
of these mappings.
Input
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
X
Y
Z
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
Output
Encryption example (N = 2, keys of X and R): The initial input
character of F gets mapped to C by the first
mapping, and this becomes the input of the second mapping.
Under the second mapping, this input
character gets mapped to T which is the encrypted output
character.
Mapping 1: Input character: F (decrypted)
partial mapping array
Mapping 2:
partial mapping array
Output character: T (encrypted)
Decryption example (N = 2, keys of X and R): Decryption
works in the opposite direction with the inputs
and outputs reversed in each mapping. The input character of T
gets mapped to C under the second
mapping, and this becomes the input of the first mapping. Under
the first mapping, this input character C
gets mapped back to F which is the decrypted output character.
Mapping 1: Output character: F (decrypted)
partial mapping array
Mapping 2:
partial mapping array
Input character: T (encrypted)
For this assignment, you need to allow the user to encrypt or
decrypt as many files as they want. The user
will need to specify the N keys and the input and output files.
Your output must look exactly like the following (user input is
in red):
********************
*
ENCRYPTION
********************
Enter
E)ncode,
D)ecode,
Q)uit:
E
Enter
Number
of
Mappings
(2--‐25):
6
Enter
the
6
keys:
OREGON
Enter
plaintext
filename:
plaintext.txt
Enter
ciphertext
filename:
ciphertext.txt
Encode
Success
Enter
E)ncode,
D)ecode,
Q)uit:
Q
Input
A B C D E F G
X Y Z A B C D
Output
Input
A B C D E F G
R S T U V W X
Output
Output
A B C D E F G
X Y Z A B C D
Input
Output
A B C D E F G
R S T U V W X
Input
Functions
You must use at least the following functions:
• void
printHeading
(const
char
heading[]);
Description: Prints the heading as displayed on the sample
output of the previous page.
• void
getMappingData
(int
&numberOfMappings,
char
key[]);
Description: Prompts the user for the number of mappings and
the keys as displayed on the
sample output. The number of mappings and keys are returned
through the parameters
numberOfMappings and key. To validate the key, you will need
to use a string function called
strlen, which returns the number of characters in the key. For
example, the following program
segment will allow the user to enter a key such as OREGON and
then output 6. You will need to
#include <string> for the use of strlen. Remember, do not
declare any string variables.
cin
>>
key;
//Typing
in
OREGON
produces
a
key
OREGON0
cout
<<
static_cast<int>(strlen
(key));
//
6
is
output
• void
openFileForRead
(ifstream
&inputFile,
const
char
message[]);
Description: Accepts a message to be displayed (e.g. Enter
plaintext filename: ), then prompts the
user to enter a plaintext file validating that the file exists and is
open. Do not proceed until a proper
file can be opened.
• void
openFileForWrite
(ofstream
&outputFile,
const
char
message[]);
Description: Similar to openFileForRead only we are writing
to a file.
• void
constructMappingArray
(char
mappingArray[][LETTERS_IN_ALPHABET],
const
char
keyArray[],
int
numberOfMappings);
Description: Using the keyArray and numberOfMappings, you
are to create the mappingArray as
discussed above.
• void
printMappingArray
(const
char
mappingArray[][LETTERS_IN_ALPHABET],
int
numberOfMappings);
Description: This function is simply for debugging. After you
create the mappingArray, print it
out to make sure you have a correct mappingArray. If not, there
is no point in going on until this
array is correct.
• char
decodeCharacter
(char
ciphertextCharacter,
const
char
mappingArray[][LETTERS_IN_ALPHABET],
int
numberOfMappings);
Description: Using the number of mappings and the
mappingArray, this function takes an
encoded character and returns a decoded character using the
process described above.
• char
encodeCharacter
(char
plaintextCharacter,
const
char
mappingArray[][LETTERS_IN_ALPHABET],
int
numberOfMappings);
Description: Using the number of mappings and the
mappingArray, this function takes a plaintext
character and returns a ciphertext character using the process
described above.
• You can add more functions as you see fit. If you only use the
functions described above, your main
function might be a little long, say around 65 lines of code.
Part A (Due Wednesday, December 2, 2015 by 1pm)
You are to implement the functions printHeading,
getMappingData, openFileForRead,
openFileForWrite, constructMappingArray, and
printMappingArray. For part A only, display the
mappingArray. You do not need to turn in a printed copy of
your program for part A. Only an electronic
copy is necessary for this part.
Part B (Due Tuesday, December 8, 2015 by 9:40am)
The completed project is due by the date and time specified
including a printed copy and an electronic
copy.
Notes
• You are to use arrays to help you encode and decode your
message.
• Do not declare any string variables in your solution. Only char
arrays are allowed.
• Be sure to validate all input. Continue asking for input until
valid input is given. The secret keys
must be uppercase letters.
• Only upper case alphabetic characters are to be encoded and
decoded --any other characters are to
be left as is and outputted. This includes any punctuation,
spaces, returns, etc.
• You need to encode your favorite joke and email the encoded
message to me by 9:40 am the day
the project is due. In the subject line of the email, specify all
the secret keys you use (at least 5).
• At least one encoded file will be placed on Grace a few days
before the assignment is due.
To complete this assignment you must submit the following:
1. An electronic copy of your program on Grace
a. Add a new project named 07_Cryptography to your
previously created assignment solution
called PUNetIDAssignments. It is vital that you name your
project correctly!
b. Type your program (fully documented/commented) into the
project. You must follow the
coding standards!
c. Pay attention to the example output! Your program’s output
must look exactly like the example
output! The spacing and newlines in your output must match
exactly.
d. Make sure that your program compiles and runs correctly. If
you get any errors, double check
that you typed everything correctly.
e. Make sure that your program does not produce any warnings.
f. Once you are sure that the program works correctly it is time
to submit your program. You do
this by logging on to Grace and placing your complete solution
folder in the CS150-01 Drop
folder. This solution folder must contain previous assignments.
g. The solution must be in the drop folder by 9:40am on the day
that it is due. Remember, there is
no late grace period for this last assignment.
2. A hard copy of your program
a. The hard copy must be placed on the instructor’s desk by
9:40am on the day that it is due.
b. The hard copy must be printed in color, double-sided, and
stapled if necessary.
c. Your tab size must be set to 2 and you must not go past
column 80 in your output.
Good luck! And remember, if you have any problems, come and
see me straight away.
START EARLY!!

More Related Content

Similar to CS150 Assignment 7 Cryptography Date assigned Monday.docx

Programming For As Comp
Programming For As CompProgramming For As Comp
Programming For As Comp
David Halliday
 
Programming with c language practical manual
Programming with c language practical manualProgramming with c language practical manual
Programming with c language practical manual
Anil Bishnoi
 
C Programming
C ProgrammingC Programming
C Programming
Adil Jafri
 
1 ECE 175 Computer Programming for Engineering Applica.docx
1  ECE 175 Computer Programming for Engineering Applica.docx1  ECE 175 Computer Programming for Engineering Applica.docx
1 ECE 175 Computer Programming for Engineering Applica.docx
oswald1horne84988
 
C language tutorial
C language tutorialC language tutorial
C language tutorial
Jitendra Ahir
 
Unit 1 c - all topics
Unit 1   c - all topicsUnit 1   c - all topics
Unit 1 c - all topics
veningstonk
 
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
eugeniadean34240
 
C notes.pdf
C notes.pdfC notes.pdf
C notes.pdf
Durga Padma
 
C++
C++C++
Char word counter in Python with simple gui - PROJECT
Char word counter in Python with simple gui - PROJECTChar word counter in Python with simple gui - PROJECT
Char word counter in Python with simple gui - PROJECT
MahmutKAMALAK
 
Class 12 computer sample paper with answers
Class 12 computer sample paper with answersClass 12 computer sample paper with answers
Class 12 computer sample paper with answers
debarghyamukherjee60
 
keyword
keywordkeyword
keyword
teach4uin
 
keyword
keywordkeyword
keyword
teach4uin
 
Cryptographic Algorithms: DES and RSA
Cryptographic Algorithms: DES and RSACryptographic Algorithms: DES and RSA
Cryptographic Algorithms: DES and RSA
aritraranjan
 
C notes for exam preparation
C notes for exam preparationC notes for exam preparation
C notes for exam preparation
Lakshmi Sarvani Videla
 
Unit-IV.pptx
Unit-IV.pptxUnit-IV.pptx
Unit-IV.pptx
Mehul Desai
 
Devry cis-170-c-i lab-5-of-7-arrays-and-strings
Devry cis-170-c-i lab-5-of-7-arrays-and-stringsDevry cis-170-c-i lab-5-of-7-arrays-and-strings
Devry cis-170-c-i lab-5-of-7-arrays-and-strings
noahjamessss
 
Devry cis-170-c-i lab-5-of-7-arrays-and-strings
Devry cis-170-c-i lab-5-of-7-arrays-and-stringsDevry cis-170-c-i lab-5-of-7-arrays-and-strings
Devry cis-170-c-i lab-5-of-7-arrays-and-strings
cskvsmi44
 
1-19 CPP Slides 2022-02-28 18_22_ 05.pdf
1-19 CPP Slides 2022-02-28 18_22_ 05.pdf1-19 CPP Slides 2022-02-28 18_22_ 05.pdf
1-19 CPP Slides 2022-02-28 18_22_ 05.pdf
dhruvjs
 
Important C program of Balagurusamy Book
Important C program of Balagurusamy BookImportant C program of Balagurusamy Book
Important C program of Balagurusamy Book
Abir Hossain
 

Similar to CS150 Assignment 7 Cryptography Date assigned Monday.docx (20)

Programming For As Comp
Programming For As CompProgramming For As Comp
Programming For As Comp
 
Programming with c language practical manual
Programming with c language practical manualProgramming with c language practical manual
Programming with c language practical manual
 
C Programming
C ProgrammingC Programming
C Programming
 
1 ECE 175 Computer Programming for Engineering Applica.docx
1  ECE 175 Computer Programming for Engineering Applica.docx1  ECE 175 Computer Programming for Engineering Applica.docx
1 ECE 175 Computer Programming for Engineering Applica.docx
 
C language tutorial
C language tutorialC language tutorial
C language tutorial
 
Unit 1 c - all topics
Unit 1   c - all topicsUnit 1   c - all topics
Unit 1 c - all topics
 
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
 
C notes.pdf
C notes.pdfC notes.pdf
C notes.pdf
 
C++
C++C++
C++
 
Char word counter in Python with simple gui - PROJECT
Char word counter in Python with simple gui - PROJECTChar word counter in Python with simple gui - PROJECT
Char word counter in Python with simple gui - PROJECT
 
Class 12 computer sample paper with answers
Class 12 computer sample paper with answersClass 12 computer sample paper with answers
Class 12 computer sample paper with answers
 
keyword
keywordkeyword
keyword
 
keyword
keywordkeyword
keyword
 
Cryptographic Algorithms: DES and RSA
Cryptographic Algorithms: DES and RSACryptographic Algorithms: DES and RSA
Cryptographic Algorithms: DES and RSA
 
C notes for exam preparation
C notes for exam preparationC notes for exam preparation
C notes for exam preparation
 
Unit-IV.pptx
Unit-IV.pptxUnit-IV.pptx
Unit-IV.pptx
 
Devry cis-170-c-i lab-5-of-7-arrays-and-strings
Devry cis-170-c-i lab-5-of-7-arrays-and-stringsDevry cis-170-c-i lab-5-of-7-arrays-and-strings
Devry cis-170-c-i lab-5-of-7-arrays-and-strings
 
Devry cis-170-c-i lab-5-of-7-arrays-and-strings
Devry cis-170-c-i lab-5-of-7-arrays-and-stringsDevry cis-170-c-i lab-5-of-7-arrays-and-strings
Devry cis-170-c-i lab-5-of-7-arrays-and-strings
 
1-19 CPP Slides 2022-02-28 18_22_ 05.pdf
1-19 CPP Slides 2022-02-28 18_22_ 05.pdf1-19 CPP Slides 2022-02-28 18_22_ 05.pdf
1-19 CPP Slides 2022-02-28 18_22_ 05.pdf
 
Important C program of Balagurusamy Book
Important C program of Balagurusamy BookImportant C program of Balagurusamy Book
Important C program of Balagurusamy Book
 

More from faithxdunce63732

Assignment DetailsScenario You are member of a prisoner revie.docx
Assignment DetailsScenario You are member of a prisoner revie.docxAssignment DetailsScenario You are member of a prisoner revie.docx
Assignment DetailsScenario You are member of a prisoner revie.docx
faithxdunce63732
 
Assignment DetailsScenario You are an investigator for Child .docx
Assignment DetailsScenario You are an investigator for Child .docxAssignment DetailsScenario You are an investigator for Child .docx
Assignment DetailsScenario You are an investigator for Child .docx
faithxdunce63732
 
Assignment DetailsScenario You are a new patrol officer in a .docx
Assignment DetailsScenario You are a new patrol officer in a .docxAssignment DetailsScenario You are a new patrol officer in a .docx
Assignment DetailsScenario You are a new patrol officer in a .docx
faithxdunce63732
 
Assignment DetailsScenario Generally, we have considered sexual.docx
Assignment DetailsScenario Generally, we have considered sexual.docxAssignment DetailsScenario Generally, we have considered sexual.docx
Assignment DetailsScenario Generally, we have considered sexual.docx
faithxdunce63732
 
Assignment DetailsPower’s on, Power’s Off!How convenient is.docx
Assignment DetailsPower’s on, Power’s Off!How convenient is.docxAssignment DetailsPower’s on, Power’s Off!How convenient is.docx
Assignment DetailsPower’s on, Power’s Off!How convenient is.docx
faithxdunce63732
 
Assignment DetailsIn 1908, playwright Israel Zangwill referred to .docx
Assignment DetailsIn 1908, playwright Israel Zangwill referred to .docxAssignment DetailsIn 1908, playwright Israel Zangwill referred to .docx
Assignment DetailsIn 1908, playwright Israel Zangwill referred to .docx
faithxdunce63732
 
Assignment DetailsPart IRespond to the following.docx
Assignment DetailsPart IRespond to the following.docxAssignment DetailsPart IRespond to the following.docx
Assignment DetailsPart IRespond to the following.docx
faithxdunce63732
 
Assignment DetailsPlease discuss the following in your main post.docx
Assignment DetailsPlease discuss the following in your main post.docxAssignment DetailsPlease discuss the following in your main post.docx
Assignment DetailsPlease discuss the following in your main post.docx
faithxdunce63732
 
Assignment DetailsPennsylvania was the leader in sentencing and .docx
Assignment DetailsPennsylvania was the leader in sentencing and .docxAssignment DetailsPennsylvania was the leader in sentencing and .docx
Assignment DetailsPennsylvania was the leader in sentencing and .docx
faithxdunce63732
 
Assignment DetailsPart IRespond to the followingReview .docx
Assignment DetailsPart IRespond to the followingReview .docxAssignment DetailsPart IRespond to the followingReview .docx
Assignment DetailsPart IRespond to the followingReview .docx
faithxdunce63732
 
Assignment DetailsPart IRespond to the following questio.docx
Assignment DetailsPart IRespond to the following questio.docxAssignment DetailsPart IRespond to the following questio.docx
Assignment DetailsPart IRespond to the following questio.docx
faithxdunce63732
 
Assignment DetailsPart IRespond to the following questions.docx
Assignment DetailsPart IRespond to the following questions.docxAssignment DetailsPart IRespond to the following questions.docx
Assignment DetailsPart IRespond to the following questions.docx
faithxdunce63732
 
Assignment DetailsOne thing that unites all humans—despite cultu.docx
Assignment DetailsOne thing that unites all humans—despite cultu.docxAssignment DetailsOne thing that unites all humans—despite cultu.docx
Assignment DetailsOne thing that unites all humans—despite cultu.docx
faithxdunce63732
 
Assignment DetailsMN551Develop cooperative relationships with.docx
Assignment DetailsMN551Develop cooperative relationships with.docxAssignment DetailsMN551Develop cooperative relationships with.docx
Assignment DetailsMN551Develop cooperative relationships with.docx
faithxdunce63732
 
Assignment DetailsInfluence ProcessesYou have been encourag.docx
Assignment DetailsInfluence ProcessesYou have been encourag.docxAssignment DetailsInfluence ProcessesYou have been encourag.docx
Assignment DetailsInfluence ProcessesYou have been encourag.docx
faithxdunce63732
 
Assignment DetailsIn this assignment, you will identify and .docx
Assignment DetailsIn this assignment, you will identify and .docxAssignment DetailsIn this assignment, you will identify and .docx
Assignment DetailsIn this assignment, you will identify and .docx
faithxdunce63732
 
Assignment DetailsFinancial statements are the primary means of .docx
Assignment DetailsFinancial statements are the primary means of .docxAssignment DetailsFinancial statements are the primary means of .docx
Assignment DetailsFinancial statements are the primary means of .docx
faithxdunce63732
 
Assignment DetailsIn this assignment, you will identify a pr.docx
Assignment DetailsIn this assignment, you will identify a pr.docxAssignment DetailsIn this assignment, you will identify a pr.docx
Assignment DetailsIn this assignment, you will identify a pr.docx
faithxdunce63732
 
Assignment DetailsHealth information technology (health IT) .docx
Assignment DetailsHealth information technology (health IT) .docxAssignment DetailsHealth information technology (health IT) .docx
Assignment DetailsHealth information technology (health IT) .docx
faithxdunce63732
 
Assignment DetailsDiscuss the followingWhat were some of .docx
Assignment DetailsDiscuss the followingWhat were some of .docxAssignment DetailsDiscuss the followingWhat were some of .docx
Assignment DetailsDiscuss the followingWhat were some of .docx
faithxdunce63732
 

More from faithxdunce63732 (20)

Assignment DetailsScenario You are member of a prisoner revie.docx
Assignment DetailsScenario You are member of a prisoner revie.docxAssignment DetailsScenario You are member of a prisoner revie.docx
Assignment DetailsScenario You are member of a prisoner revie.docx
 
Assignment DetailsScenario You are an investigator for Child .docx
Assignment DetailsScenario You are an investigator for Child .docxAssignment DetailsScenario You are an investigator for Child .docx
Assignment DetailsScenario You are an investigator for Child .docx
 
Assignment DetailsScenario You are a new patrol officer in a .docx
Assignment DetailsScenario You are a new patrol officer in a .docxAssignment DetailsScenario You are a new patrol officer in a .docx
Assignment DetailsScenario You are a new patrol officer in a .docx
 
Assignment DetailsScenario Generally, we have considered sexual.docx
Assignment DetailsScenario Generally, we have considered sexual.docxAssignment DetailsScenario Generally, we have considered sexual.docx
Assignment DetailsScenario Generally, we have considered sexual.docx
 
Assignment DetailsPower’s on, Power’s Off!How convenient is.docx
Assignment DetailsPower’s on, Power’s Off!How convenient is.docxAssignment DetailsPower’s on, Power’s Off!How convenient is.docx
Assignment DetailsPower’s on, Power’s Off!How convenient is.docx
 
Assignment DetailsIn 1908, playwright Israel Zangwill referred to .docx
Assignment DetailsIn 1908, playwright Israel Zangwill referred to .docxAssignment DetailsIn 1908, playwright Israel Zangwill referred to .docx
Assignment DetailsIn 1908, playwright Israel Zangwill referred to .docx
 
Assignment DetailsPart IRespond to the following.docx
Assignment DetailsPart IRespond to the following.docxAssignment DetailsPart IRespond to the following.docx
Assignment DetailsPart IRespond to the following.docx
 
Assignment DetailsPlease discuss the following in your main post.docx
Assignment DetailsPlease discuss the following in your main post.docxAssignment DetailsPlease discuss the following in your main post.docx
Assignment DetailsPlease discuss the following in your main post.docx
 
Assignment DetailsPennsylvania was the leader in sentencing and .docx
Assignment DetailsPennsylvania was the leader in sentencing and .docxAssignment DetailsPennsylvania was the leader in sentencing and .docx
Assignment DetailsPennsylvania was the leader in sentencing and .docx
 
Assignment DetailsPart IRespond to the followingReview .docx
Assignment DetailsPart IRespond to the followingReview .docxAssignment DetailsPart IRespond to the followingReview .docx
Assignment DetailsPart IRespond to the followingReview .docx
 
Assignment DetailsPart IRespond to the following questio.docx
Assignment DetailsPart IRespond to the following questio.docxAssignment DetailsPart IRespond to the following questio.docx
Assignment DetailsPart IRespond to the following questio.docx
 
Assignment DetailsPart IRespond to the following questions.docx
Assignment DetailsPart IRespond to the following questions.docxAssignment DetailsPart IRespond to the following questions.docx
Assignment DetailsPart IRespond to the following questions.docx
 
Assignment DetailsOne thing that unites all humans—despite cultu.docx
Assignment DetailsOne thing that unites all humans—despite cultu.docxAssignment DetailsOne thing that unites all humans—despite cultu.docx
Assignment DetailsOne thing that unites all humans—despite cultu.docx
 
Assignment DetailsMN551Develop cooperative relationships with.docx
Assignment DetailsMN551Develop cooperative relationships with.docxAssignment DetailsMN551Develop cooperative relationships with.docx
Assignment DetailsMN551Develop cooperative relationships with.docx
 
Assignment DetailsInfluence ProcessesYou have been encourag.docx
Assignment DetailsInfluence ProcessesYou have been encourag.docxAssignment DetailsInfluence ProcessesYou have been encourag.docx
Assignment DetailsInfluence ProcessesYou have been encourag.docx
 
Assignment DetailsIn this assignment, you will identify and .docx
Assignment DetailsIn this assignment, you will identify and .docxAssignment DetailsIn this assignment, you will identify and .docx
Assignment DetailsIn this assignment, you will identify and .docx
 
Assignment DetailsFinancial statements are the primary means of .docx
Assignment DetailsFinancial statements are the primary means of .docxAssignment DetailsFinancial statements are the primary means of .docx
Assignment DetailsFinancial statements are the primary means of .docx
 
Assignment DetailsIn this assignment, you will identify a pr.docx
Assignment DetailsIn this assignment, you will identify a pr.docxAssignment DetailsIn this assignment, you will identify a pr.docx
Assignment DetailsIn this assignment, you will identify a pr.docx
 
Assignment DetailsHealth information technology (health IT) .docx
Assignment DetailsHealth information technology (health IT) .docxAssignment DetailsHealth information technology (health IT) .docx
Assignment DetailsHealth information technology (health IT) .docx
 
Assignment DetailsDiscuss the followingWhat were some of .docx
Assignment DetailsDiscuss the followingWhat were some of .docxAssignment DetailsDiscuss the followingWhat were some of .docx
Assignment DetailsDiscuss the followingWhat were some of .docx
 

Recently uploaded

BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
Nguyen Thanh Tu Collection
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
NgcHiNguyn25
 
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptxNEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
iammrhaywood
 
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
สมใจ จันสุกสี
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
RAHUL
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
TechSoup
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
Celine George
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Fajar Baskoro
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
Celine George
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
siemaillard
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
HajraNaeem15
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 

Recently uploaded (20)

BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
 
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptxNEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
 
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 

CS150 Assignment 7 Cryptography Date assigned Monday.docx

  • 1. CS150 Assignment 7 Cryptography Date assigned: Monday, November 23, 2015 Date Due: Tuesday, December 8, 2015, 9:40 am (40 points) There is no late grace period for this last assignment!!!!! Cryptography is an exciting area of Computer Science concerned with hiding and protecting information. This is the branch of Computer Science that allows you to send your credit card securely to a web site or to decrypt or encrypt secret messages. For this project, you will be building a program that will take a plain text file and produce an encrypted file (or vice versa). The encryption scheme you need to implement is inspired by the Enigma Machine, a German encryption machine from WWII (http://en.wikipedia.org/wiki/Enigma_machine). The Enigma machine code was broken by Alan Turing and his team at Bletchley Park during World War II. Encryption Scheme: Simple substitution A simple substitution cipher (sometimes called a Caesar cipher) maps each letter of the alphabet to another letter of the alphabet as shown below:
  • 2. To encrypt a letter, find the letter on the top and use the letter below it as the encrypted output. Using the above table, the encrypted output for C would be Z. To decrypt a letter, find the letter on the bottom and use the letter above it as the decrypted output. To make things more interesting, a secret key is used to specify how the input characters are mapped to output characters. The key, which is a single character, specifies which letter the output row starts on. The key in the above example is X. (The input row always starts with A). N-Way Substitution You will need to implement an N-Way substitution encryption scheme. This means you will have N substitution mappings. The character to be encrypted will be used as the input to the first mapping; the output of the first mapping will be the input to the second mapping. The output of the second mapping will be the input to the third mapping, etc. The output of the N-1 mapping is the input to the N mapping, and the output of the N mapping is the encrypted character. Each mapping has its own key, so you will have a total of N secret keys for this scheme. The value N, which is specified by the user, may be between 2 and 25. You must use a single, multidimensional array to represent all of these mappings. Input A B
  • 4. G H I J K L M N O P Q R S T U V W Output Encryption example (N = 2, keys of X and R): The initial input character of F gets mapped to C by the first mapping, and this becomes the input of the second mapping. Under the second mapping, this input character gets mapped to T which is the encrypted output character. Mapping 1: Input character: F (decrypted) partial mapping array
  • 5. Mapping 2: partial mapping array Output character: T (encrypted) Decryption example (N = 2, keys of X and R): Decryption works in the opposite direction with the inputs and outputs reversed in each mapping. The input character of T gets mapped to C under the second mapping, and this becomes the input of the first mapping. Under the first mapping, this input character C gets mapped back to F which is the decrypted output character. Mapping 1: Output character: F (decrypted) partial mapping array Mapping 2: partial mapping array Input character: T (encrypted)
  • 6. For this assignment, you need to allow the user to encrypt or decrypt as many files as they want. The user will need to specify the N keys and the input and output files. Your output must look exactly like the following (user input is in red): ******************** * ENCRYPTION ********************
  • 8. filename: ciphertext.txt Encode Success Enter E)ncode, D)ecode, Q)uit: Q Input A B C D E F G X Y Z A B C D Output Input A B C D E F G R S T U V W X Output Output A B C D E F G X Y Z A B C D Input Output A B C D E F G R S T U V W X Input
  • 9. Functions You must use at least the following functions: • void printHeading (const char heading[]); Description: Prints the heading as displayed on the sample output of the previous page. • void getMappingData (int &numberOfMappings, char key[]); Description: Prompts the user for the number of mappings and the keys as displayed on the sample output. The number of mappings and keys are returned through the parameters numberOfMappings and key. To validate the key, you will need to use a string function called strlen, which returns the number of characters in the key. For
  • 10. example, the following program segment will allow the user to enter a key such as OREGON and then output 6. You will need to #include <string> for the use of strlen. Remember, do not declare any string variables. cin >> key; //Typing in OREGON produces a key OREGON0 cout << static_cast<int>(strlen (key)); // 6 is output • void openFileForRead (ifstream
  • 11. &inputFile, const char message[]); Description: Accepts a message to be displayed (e.g. Enter plaintext filename: ), then prompts the user to enter a plaintext file validating that the file exists and is open. Do not proceed until a proper file can be opened. • void openFileForWrite (ofstream &outputFile, const char message[]); Description: Similar to openFileForRead only we are writing to a file.
  • 13. int numberOfMappings); Description: Using the keyArray and numberOfMappings, you are to create the mappingArray as discussed above. • void printMappingArray (const char mappingArray[][LETTERS_IN_ALPHABET],
  • 14. int numberOfMappings); Description: This function is simply for debugging. After you create the mappingArray, print it out to make sure you have a correct mappingArray. If not, there is no point in going on until this array is correct. • char decodeCharacter (char ciphertextCharacter, const char mappingArray[][LETTERS_IN_ALPHABET],
  • 15. int numberOfMappings); Description: Using the number of mappings and the mappingArray, this function takes an encoded character and returns a decoded character using the process described above. • char encodeCharacter (char plaintextCharacter,
  • 17. int numberOfMappings); Description: Using the number of mappings and the mappingArray, this function takes a plaintext character and returns a ciphertext character using the process described above. • You can add more functions as you see fit. If you only use the functions described above, your main function might be a little long, say around 65 lines of code. Part A (Due Wednesday, December 2, 2015 by 1pm) You are to implement the functions printHeading, getMappingData, openFileForRead, openFileForWrite, constructMappingArray, and printMappingArray. For part A only, display the
  • 18. mappingArray. You do not need to turn in a printed copy of your program for part A. Only an electronic copy is necessary for this part. Part B (Due Tuesday, December 8, 2015 by 9:40am) The completed project is due by the date and time specified including a printed copy and an electronic copy. Notes • You are to use arrays to help you encode and decode your message. • Do not declare any string variables in your solution. Only char arrays are allowed. • Be sure to validate all input. Continue asking for input until valid input is given. The secret keys must be uppercase letters. • Only upper case alphabetic characters are to be encoded and decoded --any other characters are to be left as is and outputted. This includes any punctuation, spaces, returns, etc. • You need to encode your favorite joke and email the encoded message to me by 9:40 am the day the project is due. In the subject line of the email, specify all the secret keys you use (at least 5).
  • 19. • At least one encoded file will be placed on Grace a few days before the assignment is due. To complete this assignment you must submit the following: 1. An electronic copy of your program on Grace a. Add a new project named 07_Cryptography to your previously created assignment solution called PUNetIDAssignments. It is vital that you name your project correctly! b. Type your program (fully documented/commented) into the project. You must follow the coding standards! c. Pay attention to the example output! Your program’s output must look exactly like the example output! The spacing and newlines in your output must match exactly. d. Make sure that your program compiles and runs correctly. If you get any errors, double check that you typed everything correctly. e. Make sure that your program does not produce any warnings. f. Once you are sure that the program works correctly it is time to submit your program. You do this by logging on to Grace and placing your complete solution folder in the CS150-01 Drop folder. This solution folder must contain previous assignments.
  • 20. g. The solution must be in the drop folder by 9:40am on the day that it is due. Remember, there is no late grace period for this last assignment. 2. A hard copy of your program a. The hard copy must be placed on the instructor’s desk by 9:40am on the day that it is due. b. The hard copy must be printed in color, double-sided, and stapled if necessary. c. Your tab size must be set to 2 and you must not go past column 80 in your output. Good luck! And remember, if you have any problems, come and see me straight away. START EARLY!!