Exam 8: Cryptanalysis: Advanced Dictionaries and Lists, Regular Expressions
One of the most secure algorithms for encryption today is called:
B
Briefly describe how to crack a substitution cipher.
The substitution cipher is much harder to crack than the rail fence cipher. There are 26!, or roughly 4 × 10<sup>26</sup>, different possible arrangements of the alphabet that could be used as a key. Clearly, the brute force strategy for finding the key would take an extremely long time. However, the substitution cipher does have a fatal flaw that we can exploit. The flaw is that the substitution cipher allows us to take advantage of patterns in the English language that help us deduce letters in the key. The first pattern to exploit is that some letters in the English language appear more frequently than others. If we count the number of times each letter occurs in a document such as this book, or any other English language book, we would find that the letters e, t, a, o, and i are much more common than many other letters in the alphabet. Using regular expressions can also help to fill in letters of a word in the ciphertext.
Describe the function of regular expressions and explain how to use them in Python.
Regular expressions allow us to see if two strings match, much like the ==, except that in regular expressions, we can use wild card characters as part of the match. For example, we can test to see if the string .ADE matched FADE. When using regular expressions, the . character is a wildcard that matches any character. The regular expression function that we use to test if two strings match is called match. The match function takes two parameters: a regular expression and the string we want to match against.
What are the benefits of using a dictionary over a list when looking up values?
____ order takes the first row of the table and stores all the values on that row one after the other, followed by the second row and the third, and so on.
Using the setDefault pattern is efficient for adding values to a dictionary.
If we want to store a two-dimensional table in a computer's memory, we need to map from the row, column coordinates, which correspond to a cell in the table, to a location in memory.
Match each definition with its term.
-Allow us to determine what characters in a target word match letters in different
Parts of a given pattern.
What of the following is one of the most frequently occurring letters in the English language?
Case Study 2:
1. def maybeAdd(ch, toList):
2. if ch in 'abcdefghijklmnopqrstuvwxyz'
and ch not in toList:
3. toList.append (ch)
-Refer to the session in the accompanying Case Study 2. What is the value of myList after the following code is executed?
>>> myList
['a', 'b']
>>> maybeAdd('a', myList)
Case Study 1:
1. def railBreak(cipherText):
2. wordDict = createWordDict('wordlist.txt')
3. cipherLen = len(cipherText)
4. maxGoodSoFar = 0
5. bestGuess = "No words found in dictionary"
6. for i in range(2, cipherLen + 1):
7. words = railDecrypt(cipherText, i)
8. goodCount = 0
9. for w in words:
10. if w in wordDict:
11. goodCount = goodCount + 1
12. if goodCount > maxGoodSoFar:
13. maxGoodSoFar = goodCount
14. bestGuess = " ".join(words)
15. return bestGuess
-Refer to the session in the accompanying case study. What is the function of
" ")join(words) on line 14?
How can a dictionary be used to improve upon a brute force approach to decrypting a rail fence cipher?
Match each definition with its term.
-Refers to trying all possible solutions.
Case Study 1:
1. def railBreak(cipherText):
2. wordDict = createWordDict('wordlist.txt')
3. cipherLen = len(cipherText)
4. maxGoodSoFar = 0
5. bestGuess = "No words found in dictionary"
6. for i in range(2, cipherLen + 1):
7. words = railDecrypt(cipherText, i)
8. goodCount = 0
9. for w in words:
10. if w in wordDict:
11. goodCount = goodCount + 1
12. if goodCount > maxGoodSoFar:
13. maxGoodSoFar = goodCount
14. bestGuess = " ".join(words)
15. return bestGuess
-Refer to the session in the accompanying Case Study 1. What pattern is used on lines 12-14?
What three-letter word appears most often in War of the Worlds?
Explain how to identify the difference between vowels and consonants in the English language.
Some of the first computer scientists were deeply involved in cryptanalysis.
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)