Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ interesting problem I cant figure out Problem 5 (20 points): Vigenere Cipher The Vigenere cipher is a type of polyalphabetic aipher. For the Caesar

image text in transcribedimage text in transcribed C++ interesting problem I cant figure out

Problem 5 (20 points): Vigenere Cipher The Vigenere cipher is a type of polyalphabetic aipher. For the Caesar cipher each letter of the alphabet is substituted by a new letter based on a constant shift value. That makes the Caesar cipher easy enough to break. For the Vigenere cipher, the shift value is variable string keyword (explained below) rather than a fixed, constant number. One letter from the keyword is chosen in a dynamic fashion based on the position of the input letter to be encrypted. Let's below look at the encryption algorithm through the example There are two components to this type of encryption, keyword and the input text. If the keyword is TIGER and the input text we are trying to encode is BATMAN, encryption happens as follows: The first letter 'B' of BATMAN is encrypted using the rules: Input Letar ABCDEFGHIJKLMNOPQRSTUVWXYZ espae Lethe TUVWXYZABCDEFGHOJKLMNOPORS The encrypted alphabet is a regular alphabet just shifted to start from T (first letter of the keyword). Therefore, the letter 'B' becomes "U an encryption. The second letter ,A, of BATMAN is encrypted using the ries: Input Letter ABCDEFGHI J KLMNOPQRSTUVWXYZ Encrypted Lotar -JKLMNOPQRSTUVWXYZ ABCDEFGH Again, the encrypted alphabet is a regular alphabet just shifted to start from I (second letter of he keyword). Hence, he letter 'A' becomes T on encryption. The third letter T of BATMAN is encrvpted using the rules: mepet lene A DEFGHOJKLIMNOPORSTUVWXYZ Encrysted Lotter GHIJKLMNOPQRSTUVWXYZAB C DEF The letter T becomes Z on encryption The fourth leter 'M' of BATMAN is encrypted using the rules: ingut Lethe AB CDEF GHOJKLIMNOPORSTUVWXYZ Enerypted Litior FGHOUKLMNOPORSTUVWXYZA BCD The letter M becomes 'O onencryption The fifth letter A' of BATMAN is encrypted using the rules: input Letter ABCDEFGHIlJKLMNOPQRSTUVWXYZ Encrypted Le RSTUVWXYlZABCDEF G H I J K LMNOP The letter 'A' is encrypted as RNotice that this A' is encrypted differently than the first The sixth letter 'N' of BATMAN is encrypted using the rules: HIJ Input Lemer ABCDEFGkLMNOPQRsTUVWXYZ Eacrypred Lether TUVWXYZABCDE F GHIJKLMNO PQRS The letter 'N' becomes 'G' on encrypton. We can summarize this process in three steps: 1. For each input letter find the corresponding leter from the keyword. This is done by looking at the position of the letter in the imput text, then, locating the letter from the keyword at the same posiion. Note: if the keyword is shorter (has less characters) than the input text we need to loop back to the start, and use the letters from the keyword again. In the above example, notice that TIGER is shorter than BATMAN. TIGER has 5 characters. B'is the character at position 0 in BATMAN, and N is the character at position 5, and they both follow the same encryption rules, based on the character at position 0 from TIGER, he letter T 2. Create a new alphabet sequence shifted to start from the abave computed leter. 3. Find the encrypted letter for the input letter from the above created alphabet sequence. . Your function MUST be named vigenereCipher. . Your function takes three input arguments: o message a string in all capital letters with spaces. Unencoded messages I LIKE CHOCOLATE will be strings such as encoded messages will be strings such asB ANRPE PWX.PU TEorHELLO WORLD and o key-a string which is used to encrypt the message. It should be all capital letters. For e.g-TIGER. ATS. o flag a bool variable that controls whether your function will be encrypting or decrypting the given message. A value ofrue wil mean your function is encrypting the given message, and a value of Ealae will mean your function is decrypting it Your function should not print anything. Your function should return the encryptedidecrypted message: a string value. . . Examples: . If the input arguments are vigenereCipher (UNICORNS TICER",true . If the input arguments are vigenerecipher (UNI CORNSTIGER",true) If the input arguments are viganereCipher(NVOGKVYTIGER, false) the function should return vocrxvy as the encrypted message. the function should return Nvo Grv as the encrypted message. the function should return uxzcoRNs as the encrypted message In Cloud9 the ile should be called vigenereCipher.cpp and it ill be one of 5 files you need to zip together for the Homawork MFile Submission) an Moodle. Don't forget to head over to Moodle to the link 6, in the Answer Bax, paste only your function definition, not the entire program. Press the Check butlon. You can modify your code and re-submit (press Check again) as many times as you need to

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Image Databases Towards Advanced Image Retrieval

Authors: Yihong Gong

1st Edition

1461375037, 978-1461375036

More Books

Students also viewed these Databases questions

Question

9. Describe the characteristics of power.

Answered: 1 week ago

Question

3. Identify and describe nine cultural value orientations.

Answered: 1 week ago