hw2fa09 - CS1132 Fall 2009 Assignment 2 Adhere to the Code...

Info icon This preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CS1132 Fall 2009 Assignment 2 Adhere to the Code of Academic Integrity. You may discuss background issues and general solution strategies with others and seek help from course staff, but the homework you submit must be the work of just you. When submitting your assignment, be careful to follow the instructions summarized in Section 4 of this document. 1 Encryption Maintaining the confidentiality of digital data requires keeping unauthorized people from accessing that data and making the data unusable even if they are stolen. Encryption is the primary way to render information “unusable” to unauthorized parties. Encrypted text is plain text scrambled in some fashion-according to a key . The authorized user of the information will need to know this key to decode or “decrypt” the encrypted information. In this exercise, we will deal with a simple method of maintaining confidentiality through cryptography, the science of protecting sensitive data. You will learn about simple substitution ciphers, how to use them, and how to break them. 1.1 Creating a Substitution Cipher Key Simple substitution ciphers are a method of encryption in which individual letters of unencrypted text are replaced with individual letters of encrypted text. Each letter of the unencrypted alphabet is replaced with a unique letter in the encrypted alphabet. As an example, consider the following 5-letter alphabet: abcde : unencrypted alphabet or plaintext alphabet debca : encrypted alphabet or ciphertext alphabet In this case, the word ‘bead’ in plaintext would be replaced with ‘eadc’ in ciphertext. Your first task is to write a function genKey to return a substitution cipher key for the the full 26-letter alphabet. The substitution cipher key is a cell array of size 26. Each entry is a size 3 string: the first and third character in each cell are the character in plaintext and its corresponding character in ciphertext. The middle (second) character in the string is the space character (‘ ’). For the example above, the key would look like this: K= { ‘a d’, ‘b e’, ‘c b’, ‘d c’, ‘e a’ } One way to scramble the alphabet is to use the Fisher-Yates shuttle algorithm. Here is a description of how it works in this case: 1. we start with the identity cipher (each letter mapped to itself). The first position in each string will remain unchanged, we will only operate on the third position: e.g., K= { ‘a a’, ‘b b’, ‘c c’, ‘d d’, ‘e e’ } 2. Randomly select one of the elements of the cell array. Swap the 3rd characters between the strings stored in the random cell chosen and the first cell of the cell array. Suppose the 4th cell is randomly chosen, then you have the cell array shown below: K= { ‘a d’, ‘b b’, ‘c c’, ‘d a’, ‘e e’ } We then say the first element of the alphabet is “fixed.” Should the first element of the cell array be randomly selected, the resulting array would look unchanged from the original state. This is fine - although not very safe to map a character to itself in the encryption.
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern