The goal of this question is for you to break both a Shift Cipher and a Vigenere Cipher as a cipher text only adversary. This will require a small amount of programming, for reference my implementation in python is about 110 lines of code, so nothing too crazy. Two text ﬁles can be found on the class calendar where you found this exercise set. One is shift-enc and the other is vig-enc, these are cipher texts encrypted using a shift and Vigenere cipher respectively. To make your life a bit easier I have also included two supplemental ﬁles shift-freq and vig-freq that are the letter frequencies of each plain text ﬁle. Note that the sum of squares of letter distribution is slightly di↵erent than standard English, 0.066 in both cases.
• Break the shift cipher. To demonstrate success provide for me the ﬁrst 50 or so characters along with what key (shift was used).
• Break the Vigenere cipher. Again, to demonstrate success provide both the ﬁrst 50 or so characters and the recovered key. Hint, you should be able to call into the overwhelming majority of your shift cipher code, saving you some time.
• Provide either a description of how your program functions or include a copy of the source code. In general I would rather see source code, but if it is especially bulky a written summary is acceptable.
2. Chosen Plaintext Attackers and Classical Ciphers
Show that the shift, substitution, and Vigenere ciphers are all trivial to break for an adversary executing a chosen plaintext attack. How much chosen plaintext is needed to recover the key for each of the ciphers?
3. Repeated Uses of OTPs
We know that One Time Pads are Perfectly Secret, assuming that the key size is the same as the message size and that we do not re-use keys. Demonstrate that if a OTP is re-used multiple times the cipher is no longer perfectly secret. To do this build a Cipher Text Only attack which recovers the OTP pad given “enough” cipher texts. For a fun historical note, you are replicating an attack launched by American cryptographers during the cold war against Soviet diplomatic messages.
These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.# distribution
from builtins import print
DISTRIBUTION = 0.066
SIZE = 26
a = ord('a')
# initialize q and p array
q = 
p = 
for i in range(SIZE):
# open cipher file
cipherFile = open('shift-enc.txt', 'r')
# read file to count characters
cipherLen = 0
for ch in cipherFile.read():
# get its ascii value
t = ord(ch) - a
q[t] = q[t] + 1
cipherLen = cipherLen + 1
# calculate frequency of each encrypted character
index = 0
while index < len(q):
q[index] = q[index] / cipherLen
index += 1
# read frequency file
with open('shift-freq.txt', 'r') as f:
for line in f:
y = line.split(",")
# print(y, ' ' , float(y))
t = ord(y) - a
p[t] = float(y)
# try to break the encrypted code
k = 0
diff = 1.0...
By purchasing this solution you'll be able to access the following files: