## Encryption and the Enigma Machine## Nifty Assignments - SIGCSE 2009 |

Creighton University

davereed@creighton.edu

http://dave-reed.com

Summary | These three independent but related assignments center on encryption, building to a software simulation of a complete Enigma machine. |
---|---|

Topics | The context for these assignments is encryption. Students are introduced to the role of encryption in military and computing history, the historical significance of the Enigma machine, and it internal workings. The programming components involve class modification, class design and implementation, string manipulation, and simple GUI design. |

Audience | The first two assignments could easily be given in a CS1 course, the first fairly early as it only involves making modifications to existing classes. The second assignment requires students to design and implement classes from scratch, and so might come later in CS1. The third assignment is significantly more complex, with non-trivial design decisions involving interacting classes. It could be assigned toward the end of an advanced CS1 course, or more likely in CS2. |

Strengths | Students prefer assignments with a real-world context to those they perceive as "artificial" or "made-up." In addition, each of these assignments can involve a hands-on activity, building a paper model of the encryption scheme being discussed. Not only can this be a fun diversion in class, but the physical model can help students to understand the system they are assigned to implement in software. |

Weaknesses | The second and third assignments require students to design and implement programs from scratch. Design guidance may need to be provided, depending on timing and the ability of students. Also, instructors should be aware that there are Enigma simulator programs available on the Web. Most are highly sophisticated, and are easily spotted if copied by students. |

Dependencies | All three of these assignments require students to be familiar with class structure and String manipulation methods. The second and third require increasing degrees of class design maturity, as well as GUI design. If desired, the instructor could provide a GUI class to students to simplify that component. The three assignments are independent, but are related in terms of content area. If desired, the instructor could assign two or all three assignments in the same class. |

Cryptography has played an important role in the history of computing, from motivating the development of the first electronic computer to enabling secure Web-based communication and commerce. Substitution ciphers, such as the Caesar cipher, are simple to understand yet form the basis of many modern encryption tools, such as the Enigma machine used in World War II.

Below are three independent but related assignments involving substitution ciphers. The first assignment could be given early in a CS1 course, after String methods have been introduced. Students are given a class for encoding/decoding text using the Caesar cipher, which they must then modify to make it more robust and powerful (by allowing different substitution keys and subsequently rotating the key after each encoding). The second and third assignments extend the idea of a rotating substitution cipher, requiring students to design and implement classes for modeling an Enigma machine. The first of these involves a simplified model of an Enigma machine, using multiple interconnected, rotating substitution keys. The last is a more complex but historically accurate model of an Enigma. To help students visualize the workings of the machine, they first build a working model out of paper using the Do-It-Yourself Enigma Machine.

These assignments are "nifty" in that they combine class design, String manipulation, and GUI implementation with a broader historical context. In addition, building a working Enigma model with scissors and tape is a fun hands-on activity for the classroom.

This assignment briefly describes substitution ciphers and their significance in commercial and military history. Students are provided with two working classes, a class that implements a simple Caesar cipher and an accompanying driver class for encoding/decoding text files. They are then asked to generalize this code to handle capitals and non-letters and to allow different substitution keys. The idea of strengthening codes by adding rotation to the substitution key is then introduced, and students must add this new feature to their code.

This assignment briefly describes the historical significance of the Enigma machine, and presents a simplified model of its behavior in the form of a rotating, 3-ring cipher disk. It also directs students to a paper template from which they can build their own cipher disk. This physical model can be helpful in understanding the behavior of the rotating cipher disks and the encoding process. Once students are familiar with the behavior of the model, they are asked to design and implement a software simulation of the 3-ring cipher disk.

This assignment briefly describes the historical significance of the Enigma machine and its internal workings, with a link to more detailed information at Wikipedia. It also directs students to the Do-It-Yourself Enigma machine, a 3-dimensional paper model of the Enigma machine that they can build themselves. This physical model can be very helpful in understanding the complex behavior of the Enigma, and makes an engaging hands-on activity in class. Once students are familiar with the behavior of the model, they are asked to design and implement a software simulation of the Enigma machine.

Extra info about this assignment: