Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

HASKELL --- There is an answer already but I do not understand the logic behind it. PLEASE provide explanation of the code. 8. vigenere String

HASKELL --- There is an answer already but I do not understand the logic behind it. PLEASE provide explanation of the code.

image text in transcribed

8. vigenere String - String -> String The Vigenere encryption scheme is similar to the Caesar cipher presented in class in that it makes use of shifting, but instead of a single numeric key applied uniformly to the entire plain text, a string of characters is used as the key. The numeric value of each character (as its position in the alphabet) is used as a shift value, and if the key is shorter than the length of the plain text it is simply repeated E.g., to encrypt the plain text "FOOBAR" with the key "BAZ", we can proceed as follows: 1. Paireach letter of the plain text with a letter from the key: F O O B A R B AZ BA Z 2. Convert each letter to its numeric value (A-0, B-1. Z-25) 5 14 14 1 0 17 1025 1025 3. Add them together: 6 14 39 2 0 42 4. "Wrap" the numbers around so they're in the range 0-25: 6 14 132 0 16 5. Convert the numbers back into letters: Write a function that takes a key and plain text and returns the Vigenere encrypted cipher text. Plain text can contain a mix of lowercase and uppercase letters and punctuation, but all letters will be interpreted as uppercase. Punctuation will not be encrypted. The key will contain only letters (lower or upper case), but again will only be interpreted as uppercase 8. vigenere String - String -> String The Vigenere encryption scheme is similar to the Caesar cipher presented in class in that it makes use of shifting, but instead of a single numeric key applied uniformly to the entire plain text, a string of characters is used as the key. The numeric value of each character (as its position in the alphabet) is used as a shift value, and if the key is shorter than the length of the plain text it is simply repeated E.g., to encrypt the plain text "FOOBAR" with the key "BAZ", we can proceed as follows: 1. Paireach letter of the plain text with a letter from the key: F O O B A R B AZ BA Z 2. Convert each letter to its numeric value (A-0, B-1. Z-25) 5 14 14 1 0 17 1025 1025 3. Add them together: 6 14 39 2 0 42 4. "Wrap" the numbers around so they're in the range 0-25: 6 14 132 0 16 5. Convert the numbers back into letters: Write a function that takes a key and plain text and returns the Vigenere encrypted cipher text. Plain text can contain a mix of lowercase and uppercase letters and punctuation, but all letters will be interpreted as uppercase. Punctuation will not be encrypted. The key will contain only letters (lower or upper case), but again will only be interpreted as uppercase

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

Building The Data Warehouse

Authors: W. H. Inmon

4th Edition

0764599445, 978-0764599446

More Books

Students also viewed these Databases questions