Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Pythton : Here we will break a Hill cipher with block size 2 using frequency analysis. First lets see how to work with matrices mod

Pythton : Here we will break a Hill cipher with block size 2 using frequency analysis.

First lets see how to work with matrices mod 26

We can define a Matrix M modulo 26 as follows.

R = IntegerModRing(26) M = Matrix(R,[[3,1],[2,3]])

Now we could find the inverse of M:

M^(-1)

Now define the Hill Cryptosystem

system=HillCryptosystem(AlphabeticStrings(),2) R=IntegerModRing(26) alphabet=AlphabeticStrings()

We can encrypty a message using M:

plaintext=alphabet.encoding("HILLCIPHERSARECOOL") ciphertext=system.enciphering(M,plaintext) ciphertext

%md ## And decrypt it:

And decrypt it:

system.enciphering(M^(-1),ciphertext)

Question:

#1. We intercept the message below, saved to CT:

CT=AlphabeticStrings().encoding("BZKIKNZIXUUKGKEQZAUVSQHMEPMAHMEPDKZWIFQDJMNAFNVGBISRIVFCBZSIMAVOOSKUGKBIVGJMZGEXNOKSYRGCCKMDJIBZOVUKFNEXYNZIXAMUANABOIRQIXQABIZAUVKQVBABLAIEBVEQANLACYYKFOEMISWNGDYMFNDSCVANRMBWANACDZCVSQPMSNWWRMREANXKBMBIGDAFSQNBQIBWZMEATEPIMIRQFTMWICBZWOANQKUKSRCOTJSWQKMYFWJMXTQIBWZMIETJIVBZKIKNZINUBIKNIVFCSKXNEQXNWYYRGDUIRMKKJPAOBZGVWOANBELEFWHMEPAFUDAVNOEDXCVGUINOKNANXGDWSRZIIEFWSRCDQDSWBIGOIVEAANQVOVMMAKABGEOEILMBOVTROCDIQYOVLASPQIDVEXLOEXTIBZANVGMXDIKFGDRMYNWVEVBWEPKAWARAVZNOWYYRGDUIAFSQLOJNSPRQAKBZOVTEQPDWAFUPWNWVOIRNBIIVFXYCBZIVBIUAQSRVJTNOWYJZODKQOHGCRNCPBELEFWZIFYXAWNKQCODWLXCITMTAKFEAHCTJAVHMUYGDAFSQZBNONOQQZBQVIVTEPICVHMEPIPGENVWAZAPODISROVQKSXC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GDUIOHGCNAYKQVHMLAJWKNLMQEBZQVWVOOPOZTKVJYFILODWJZGDQDUWLOGXOVEXEPWIBZKNBZWIDIWRAVSPPTOVBZKNKXSIUCXJHKTJGDLWRQGSBZBZWILAANJTPOLZWIIENNOPPCXGSNPCIEGOUINOLWRQKXAQKXYIKQSKUXWIANPTOVMVCDUIBZKQHMUYGSBZBZCVGCOVRMTEPIMIRQANLGEPJZSPBZKIKNZIRHOILXCPZZUIIXKJUVQIPMOKQDPOFNDWWNUIBZKIKNZIXUXNAQUVCPBZUILOZEEVCIJZYCKALAHMURQBSKISMNEPRMVGUKFPAVNOKNLMQEGDCMQVHMLAJWAKUYHMUYFWJMDVWIWYMUUKJMDWLREPCIONBWXNNOWYJZODTRYCKQGDIZNOWYYRGDUIBZKNNOGSTJKXGCBZMIPVZIAKLAHICACPXJAFOVQIBABZGDUMGXICQKFPGVGVANCMOBANDTBWUIGDRMBZUICU")

#2. We now define a function that counts how often pairs of letters occur in a message:

For example:string=alphabet.encoding("COCONUTS") countBigrams(string)

CO : 2 TS : 1 NU : 1

Problem: Use this and the frequency of digrams (pairs of English letters) here: https://en.wikipedia.org/wiki/Bigram#Bigram_frequency_in_the_English_language to decrypt the message.

(Make guesses as to what you think pairs of letters encrypt to, and then find the encryption matrix the same way as the known plaintext attack

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

Programming The Perl DBI Database Programming With Perl

Authors: Tim Bunce, Alligator Descartes

1st Edition

1565926994, 978-1565926998

More Books

Students also viewed these Databases questions

Question

Name this molecule. C-C-C-C- C-C-C-C C-

Answered: 1 week ago

Question

Evaluate the combinations 11. C 6

Answered: 1 week ago

Question

Lab 1 : Social Engineering Attack

Answered: 1 week ago

Question

Explain the various techniques of Management Development.

Answered: 1 week ago

Question

4. Identify the challenges facing todays organizations

Answered: 1 week ago