You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: assign1/README.md
+29-36Lines changed: 29 additions & 36 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
# Assignment 1: Cryptography
2
-
**Due: Midnight, Tuesday of Week 5 (Febuary 3, 2019)**
2
+
**Due: Midnight, Tuesday of Week 5 (Febuary 4, 2020)**
3
3
4
4
## Overview
5
5
In this assignment, you will build a cryptography suite that implements two or three different cryptosystems - Caesar cipher, Vigenere cipher, and (optionally) the Merkle-Hellman Knapsack Cryptosystem. This handout will walk you through the details of building this text-based cryptography tool. We want to instill good Pythonic practices from the beginning - so we encourage you to think critically about writing clean Python code.
@@ -32,6 +32,21 @@ res/mh-plain.txt and res/mh-cipher.txt
32
32
```
33
33
34
34
# Cryptography Suite
35
+
## General Tips
36
+
37
+
You'll be modifying a lot of strings in this assignment. The `string` module exports some useful values:
In this section, you will build cipher functions to encrypt and decrypt messages. We'll give a brief overview of each cipher and give some pointers on how it fits it into the starter files.
@@ -142,16 +157,7 @@ These functions take two arguments, a message to encrypt (or decrypt) and a keyw
142
157
143
158
Notes:
144
159
145
-
- You can assume that all characters in the plaintext, ciphertext, and keyword will be alphabetic (i.e no spaces, numbers, or punctuation).
146
-
- However, the text of `not_a_secret_message.txt` contains spaces, numbers, and punctuation, so if you want to decrypt that, you'll need to write code that handles non-alphabetic characters. Non-alphabetic characters will not be encrypted, and do not use up any of the characters from the key. For example:
147
-
148
-
```
149
-
ATTACK AT DAWN!
150
-
+ LEMONL EM ONLE
151
-
-----------------
152
-
LXFOPV EF RNHR!
153
-
```
154
-
160
+
- You can assume that all characters in the plaintext, ciphertext, and keyword will be alphabetic (i.e no spaces, numbers, or punctuation).
155
161
- You can assume that all of the characters will be provided in uppercase.
156
162
- You can assume that keyword will have at least one letter in it.
157
163
@@ -173,7 +179,15 @@ Another list of non-exhaustive tests are available at `tests/vigenere-tests.txt`
173
179
174
180
You can use the functions `ord` and `chr` which convert strings of length one to and from their ASCII numerical equivalents. For example, `ord('A') == 65`, `ord('B') == 66`, ..., `ord('Z') == 90`, and `chr(65) == 'A'`, `chr(66) == 'B'`, ..., `chr(90) == 'Z'`. For an extra challenge, try to implement these functions purely functionally.
175
181
176
-
Intrigued? Take a look in `not_a_secret_message.txt`. One possible extension is to try to decrypt this message (or any encrypted message!) despite not knowing what the key is. For this encryption, ignore non-alphabetic characters entirely.
182
+
Intrigued? Take a look in `not_a_secret_message.txt`. One possible extension is to try to decrypt this message (or any encrypted message!) despite not knowing what the key is. For this encryption, ignore non-alphabetic characters entirely. In particular, non-alphabetic characters do not use up any of the characters from the key. For example:
183
+
184
+
```
185
+
ATTACK AT DAWN!
186
+
+ LEMONL EM ONLE
187
+
-----------------
188
+
LXFOPV EF RNHR!
189
+
```
190
+
177
191
178
192
## Console Menu
179
193
@@ -240,36 +254,15 @@ Stylistically, you will be evaluated on your general program design (a la 106 se
240
254
241
255
You can find a tool to help format your code [online](http://pep8online.com/). If you have any questions, please don't hesitate to let us know. Think about the [Zen of Python](https://www.python.org/dev/peps/pep-0020/) when making design decisions.
242
256
243
-
## Deliverables
257
+
## Submitting
258
+
259
+
Submit the following files:
244
260
245
261
1. Your modified `crypto.py`
246
262
2. The `design.txt` file documenting your design decisions
247
263
248
-
## Submitting
249
-
250
264
See the [submission instructions](https://github.com/stanfordpython/python-handouts/blob/master/submitting-assignments.md) on the course website.
Public-key cryptography is essential to modern society. You may have heard of RSA - one of the most popular public-key cryptosystems. Less well known, however, is the Merkle-Hellman Knapsack Cryptosystem, one of the earliest public-key cryptosystems (invented in 1978!), which relies on the NP-complete subset sum problem. Although it has been since been broken, it illustrates several important concepts in public-key cryptography and gives you lots of practice with the Pythonic constructs we've discussed in this class.
0 commit comments