In what concerns the continuous evaluation solving exercises grade during the semester, you should submit until 23:59 of December 7th
(this exercise will still be available for submission after that deadline, but without counting towards your grade)
[to understand the context of this problem, you should read the class #08 exercise sheet]
In this problem you should submit a function as described. Inside the function do not print anything that was not asked!
Bran Stark, with his newfound abilities as the Three-Eyed Raven, needs to send a secure message to allies across the realm. To keep the message hidden from enemies, Bran decides to use the Vigenère cipher, a method of encrypting alphabetic text by using a keyword to shift letters in a repeating pattern. The Vigenère cipher is more secure than the simple Caesar cipher because it uses a series of shifts determined by the keyword.
Imagine for instance that text to cipher is "attackatdawn" and the keyword is "fog". Then:
Write two functions:
In both methods the keyword will always be a string made only of lowercase letters. As to what regards the text, it can have any type of character, but you should only shift the letter characteres. Note that the case of the letter (upper or lower case) should be kept in the encrypted/decrypted text and that the i-th letter of the text should always be shifted using the alphabet position of the i-th letter of the keyword.
The following limits are guaranteed in all the test cases that will be given to your program:
1 ≤ |text| ≤ 200 | length of the text | |
1 ≤ |keyword| ≤ 20 | length of the keyword |
Example vigenere_encrypt() Function Calls | Example Output |
print(vigenere_encrypt("attackatdawn", "fog")) print(vigenere_encrypt("Attacking tonight?", "lemon")) print(vigenere_encrypt("Winter is Coming!", "stark")) |
fhzfqqfhjfkt Lxfopvmzu eszwtsx? Obnkoj ij Uhmzxy! |
Example vigenere_decrypt() Function Calls | Example Output |
print(vigenere_decrypt("Obnkoj ij Uhmzxy!", "stark")) print(vigenere_decrypt("Opizf vg ais Efhhcu", "hbo")) print(vigenere_decrypt("EpsDfqqxMzcjyNckUcacdWjrcBvrWinlOwu", "lion")) |
Winter is Coming! House of the Dragon TheQuickBrownFoxJumpsOverTheLazyDog |