Answered step by step
Verified Expert Solution
Question
1 Approved Answer
* Write a function ` vigenere _ decrypt ` using the following template. The ` method ` keyword argument allows the user to specify whether
Write a function vigeneredecrypt using the following template. The method keyword argument allows the user to specify whether they wish to use the Kasiski method or the Index of Coincidence method to find the key length. If no method is specified, the Kasiski method is used by default.
def vigeneredecryptY keystart keyend method"kasiski":
Y onlylettersY case"upper" # Remove spaces
if method "kasiski":
keylengthfn keylengthkasiski
elif method "coincidence":
keylengthfn keylengthcoincidence
else:
raise ValueErrorkeylength should be either "kasiski" or "coincidence"
k keylengthfnY keystartkeystart, keyendkeyend # k is the predicted key length
shifts # The predicted shift amounts
X # The predicted plaintext. Use your vigenere function from high above
return Xlower
Try to decrypt the above ciphertext from Section of the textbook.
Y zpgdl rjlaj kpylx zpyyg lrjgd lrzhz qyjzq repvm swrzy rigzh
zvreg kwivs saolt nliuw oldie aqewf iiykh bjowr hdogc qhkwa
jyagg emisr zqoqh oavlk bjofr ylvps rtgiu avmsw lzgms evwpc
dmjsv jqbrn klpcf iowhv kxjbj pmfkr qthtk ozrgq ihbmq sbivd
ardym qmpbu nivxm tzwqv gefjh ucbor vwpcd xuwft qmoow jipds
fluqm oeavl jgqea lrkti wvext vkrrg xani'
vigeneredecryptY
Select one of your classmate's Vigenre ciphertexts that were posted on Canvas Discussion and attempt to decrypt it using your vigeneredecrypt function. Assign the ciphertext to the variable name Yuse triple quotation marks to allow line breaks Try using both key length methods.
vigeneredecryptY method"kasiski"
and
vigeneredecryptY method"coincidence"
Do they both wok?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started