Question: Modified Vigenere Cipher Key programming concepts: strings Approximate lines of code: 22 (does not include comments or white space) Commands you cant use: N/A What

Modified Vigenere Cipher

Key programming concepts: strings Approximate lines of code: 22 (does not include comments or white space) Commands you cant use: N/A What to submit: A single .cpp file with your initials, underscore, and homework (e.g. ijh HW6.cpp) Autograder: Available 12:00 pm Wednesday October 17th

Program Input

Enter message to decrypt:

Enter secret key:

The user will always enter text for all prompts, no error checking needed. The secret key will always be lower case to start.

Program Outputs

Updated key: XXX Replace XXX with the adjusted secret key

Decrypted message: YYY Replace YYY with the deciphered message

Assignment Details

This assignment will give you a brief introduction into cryptography using a modified Vigenere Cipher! Cryptography allows us to encode and decode messages that are difficult to decipher without knowledge of a secret key/table/rules. Cryptography is a rich subject in its own right, and we will not have time to cover it in detail. Please check out the numerous online resources if you want more information: http://www.braingle.com/brainteasers/codes/index.php

This particular cipher depends upon a secret key (a single word, lowercase letters only) that is paired with a phrase. For example, given the phrase:

the user could choose the secret key:

Attack Now!

woot

The first step to encryption is to repeat the letters in secret key backwards until it has the same amount of letters as the message, skipping any spaces or punctuation! So with woot as the key, repeat the letters w, o, o, t for each letter in Attack Now! backwards. Note that you must also change the letters in the key to upper case if the letters in phrase are upper case.

1

A

t

t

a

c

k

N

o

w

!

W

t

o

o

w

t

O

o

w

!

Now each letter in the secret message determines how far to shift the corresponding letter in the updated key. Essentially, take the position in the alphabet (starting from 0) of the letters in message and then shift the letters in your updated key by that amount (like a Caesar Cipher). Any letters that leave the alphabet range must be rotated back in. Also, treat upper case and lower case letters as two different alphabets. Here is a detailed breakdown:

Letter in message

Alphabet pos. (from 0)

Letter in key

Encrypted letter

A

0

W

W

t

19

t

m

t

19

o

h

a

0

o

o

c

2

w

y

k

10

t

d

N

13

O

B

o

14

o

c

w

22

w

s

!

!

Following this table, Attack Now! becomes Wmhoyd Bcs!. To decode this message for the homework, do the reverse of this process!

Sample Output The following test cases do not cover all possible scenarios (develop your own!) but should

indicate if your code is on the right track.

Test Case 1:

Enter message to decrypt: Wmhoyd Bcs! Enter secret key: woot Updated key: Wtoowt Oow! Decrpyted msg: Attack Now! 

Test Case 2:

Enter message to decrypt: Iecg Nhrt Zluahept Enter secret key: alton Updated key: Anot Lano Tlanotla Decrpyted msg: Iron Chef Gauntlet 

2

COP2271 C++ Fall 18 Assignment 6 Due: October 23rd at 11:59 pm

Test Case 3:

Enter message to decrypt: Abuv jt abuv, nbhi jg nbhi! Enter secret key: bob Updated key: Obbo bb obbo, bbob bo bbob! Decrpyted msg: Math is math, math is math! 

Test Case 4:

Enter message to decrypt: Uotl ox! Kn xaapv apl qmklo. Enter secret key: lucius Updated key: Culs ui! Cu lsuic uls uicul. Decrpyted msg: Suit up! It might get weird. 

Test Case 5:

Enter message to decrypt: Ybx hoaw xayn, coh zetpk xayn whbzw. Enter secret key: edna Updated key: And eand eand, ean deand eand eande. Decrpyted msg: You dont talk, you watch talk shows. 

Useful string commands

Feel free to use the following string commands to help with the homework! Check any online C++ help or the class notes for more information on using each command:

.size() - returns the number of characters in a string isalpha - returns true if a character is an alphabet letter isspace - returns true if a character is a space ispunct - returns true if a character is a punctuation mark islower - returns true if a character is lowercase isupper - returns true if a character is uppercase tolower - changes a letter to lowercase toupper - changes a letter to uppercase values

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!