Frequency analysis attack to break a vigenere cipher assignment

Anonymous
timer Asked: Feb 23rd, 2019
account_balance_wallet $25

Question Description

Specifications: The program should take one input file which contains the text to decrypt. Assuming that the Vigenere cipher is repeating a key of length 2, write the code to break the cipher and output the two letter key and the plaintext to stdout. The code should be runnable through command line in the following way (assume the program is named as freqvis)

freqvig input_file.txt

key=xy

output_text

Test

Input text:

“pnb yxc x ybiokq rfzqrb iikxxftd gkj x ybiokq rfzqrb nlz jgak ll oapzfi muikp gkj pnb nxj kksko hbkk nbxb hbllxb yek okxrffbj fz tgp zek nafkq vigzk tnbxb zek dxlcftd vekxyxtqy tkok okxxbj qnb qbkmko ok nfy pnfxq yikbbby tgp qkkbrftd nxsjkookm qnb jlm qxlzqka llxtgoj toqn x yeuoz pnxxm hxxh gkj qnb qbkmko rflqka nfy cgzk paajbtie xta yxc eko nb nxj x yqgozika rluh ok nfy beb

ek pzogfmezbtbj eojybrc gkj pgiaqka cxzznftd nbx ft poikkib gp yek zgjk cuocxxa cfze cbghkkokm iojhp nb xbybtqka zek ftqxryfuk nb iekoopnbj eop ylrfzrjb gp nfy ltie xta rxyq lokbjls ft iock”

Output:

Key= xg

“She saw a secret little clearing and a secret little hot made of rustic poles And she had never been here before She realized it was the quiet place where the growing pheasants were reared the keeper in his shirt sleeves was kneeling hammering The dog trotted forward with a short sharp bark and the keeper lifted his face suddenly and saw her He had a startled look in his eyes

He straightened himself and saluted watching her in silence as she came forward with weakening limbs He resented the intrusion he cherished his solitude as his only and last freedom in life.”

Submission

Submit your code, the output for the following input (named output.txt) in separate files via Blackboard by the due date. No zipped files allowed.

Input to decrypt:

“bf vjrhmsgseqlal, xkwjmxfvq tftdrkbk tdlg dfhog sl uhmglbfz dxlmwkk bk mzx kmmwq hx mzx xkwjmxfvq hx ewmlxjl gk ykgnhl gy dxlmwkk bf t ubhawklxpm law fwmzhv bk nkxv tk tf taw lh tkwtcbfz ueslkbutd vaizxjl

xkwjmxfvq tftdrkbk bk uslww gg law ysvl mztl, bf tfr ybnxf llkwmua gy okamlxf esgynszw vwkltag dxlmwkk tfw uheuagsmahfl gy dxlmwkk huvmk obla ntjragy yjxinwgubwl ehjxgowk lawkw bk t uasksvlxjbkmav vbkmjbtnlbgg gy dxlmwkk mztl bk kgnyadr law lsfw ygk seehkm sed lsfhewl gy lasm dtfzmtyx xhj bflltfvw zaowg s lwvlbgg gy wgyealz esgynszw x l t sgv h skw mzx ehkm uhefgg, oaaew s i tfw p tjx jtjx dbcxobkx la wk gg sgv tf tjx law fgll vgfehf isbjl gy dxlmwkk mwkexv uazjtel gk vbyksizl sgv lk xw ml tfw xy skw mzx ehkm uhefgg jxhxsmk”

Attachment preview

Using any programming language of your choice implement the Frequency analysis attack to break a vigenere cipher that is using a key of length 2Specifications: The program should take one input file which contains the text to decrypt. Assuming that the Vigenere cipher is repeating a key of length 2, write the code to break the cipher and output the two letter key and the plaintext to stdout. The code should be runnable through command line in the following way (assume the program is named as freqvis)

freqvig input_file.txt

key=xy

output_text

Test

Input text:

“pnb yxc x ybiokq rfzqrb iikxxftd gkj x ybiokq rfzqrb nlz jgak ll oapzfi muikp gkj pnb nxj kksko hbkk nbxb hbllxb yek okxrffbj fz tgp zek nafkq vigzk tnbxb zek dxlcftd vekxyxtqy tkok okxxbj qnb qbkmko ok nfy pnfxq yikbbby tgp qkkbrftd nxsjkookm qnb jlm qxlzqka llxtgoj toqn x yeuoz pnxxm hxxh gkj qnb qbkmko rflqka nfy cgzk paajbtie xta yxc eko nb nxj x yqgozika rluh ok nfy beb

ek pzogfmezbtbj eojybrc gkj pgiaqka cxzznftd nbx ft poikkib gp yek zgjk cuocxxa cfze cbghkkokm iojhp nb xbybtqka zek ftqxryfuk nb iekoopnbj eop ylrfzrjb gp nfy ltie xta rxyq lokbjls ft iock”

Output:

Key= xg

“She saw a secret little clearing and a secret little hot made of rustic poles And she had never been here before She realized it was the quiet place where the growing pheasants were reared the keeper in his shirt sleeves was kneeling hammering The dog trotted forward with a short sharp bark and the keeper lifted his face suddenly and saw her He had a startled look in his eyes

He straightened himself and saluted watching her in silence as she came forward with weakening limbs He resented the intrusion he cherished his solitude as his only and last freedom in life.”

Submission

Submit your code, the output for the following input (named output.txt) in separate files via Blackboard by the due date. No zipped files allowed.

Input to decrypt:

“bf vjrhmsgseqlal, xkwjmxfvq tftdrkbk tdlg dfhog sl uhmglbfz dxlmwkk bk mzx kmmwq hx mzx xkwjmxfvq hx ewmlxjl gk ykgnhl gy dxlmwkk bf t ubhawklxpm law fwmzhv bk nkxv tk tf taw lh tkwtcbfz ueslkbutd vaizxjl

xkwjmxfvq tftdrkbk bk uslww gg law ysvl mztl, bf tfr ybnxf llkwmua gy okamlxf esgynszw vwkltag dxlmwkk tfw uheuagsmahfl gy dxlmwkk huvmk obla ntjragy yjxinwgubwl ehjxgowk lawkw bk t uasksvlxjbkmav vbkmjbtnlbgg gy dxlmwkk mztl bk kgnyadr law lsfw ygk seehkm sed lsfhewl gy lasm dtfzmtyx xhj bflltfvw zaowg s lwvlbgg gy wgyealz esgynszw x l t sgv h skw mzx ehkm uhefgg, oaaew s i tfw p tjx jtjx dbcxobkx la wk gg sgv tf tjx law fgll vgfehf isbjl gy dxlmwkk mwkexv uazjtel gk vbyksizl sgv lk xw ml tfw xy skw mzx ehkm uhefgg jxhxsmk”

Tutor Answer

Tellos
School: Cornell University

At...

flag Report DMCA
Review

Anonymous
Excellent job

Similar Questions
Hot Questions
Related Tags
Study Guides

Brown University





1271 Tutors

California Institute of Technology




2131 Tutors

Carnegie Mellon University




982 Tutors

Columbia University





1256 Tutors

Dartmouth University





2113 Tutors

Emory University





2279 Tutors

Harvard University





599 Tutors

Massachusetts Institute of Technology



2319 Tutors

New York University





1645 Tutors

Notre Dam University





1911 Tutors

Oklahoma University





2122 Tutors

Pennsylvania State University





932 Tutors

Princeton University





1211 Tutors

Stanford University





983 Tutors

University of California





1282 Tutors

Oxford University





123 Tutors

Yale University





2325 Tutors