Lab 10: RSA Encryption

In Prelab, we walked through an example of how RSA encryption works. We will now see how it is implemented in python.

Preliminaries

RSA Encryption

  1. The comments above the function keyGenerate are missing. Please complete them in RsaWindow.py. # function: keyGenerate # description: # input: # output: # side effects: Hint: The input parameter self is a reference to the RsaWindow itself. Do not worry about the details of this.
  2. What is the function crypt used for? (Hint: look at the two locations in the code where the method is called, the method crypt itself, and lecture notes).

Rotation Encryption

At the top of the page, please note that there are two flags: For this part of the lab, we will be using the rotation encryption method described in class. In order to change the encrpytion scheme, please take the following steps:
  1. At the top of RsaWindow.py, set rsaFlag=0. Click the Load Program button and try running the program again to verify that no encryption is used (ie, the message, encrpyted message, and decrpyted message are all the same).
  2. We will now create the method rotation, which takes in the asciiValue (a BigInteger between 0 and 65535) and rotates it by the number of characters indicated by the parameter numRotations. (The encrpyted message can go out of the range 0-65535). Don't forget to comment your code! ################### Edit This Function for the Rotation Encrpytion part of the lab ############################### # function: rotation # description: # input: # output: # side effects: def rotation(self, asciiValue, numRotations): pass Hint 1: We can create a big integer with value k as follows: BigInteger.valueOf(k)
    Hint 2: Remember the API from prelab?
  3. Change the decrpytit function by removing the line decryptedAscii = letter and replacing it with something of the form: decryptedAscii = self.rotation(value1,value2) where you must determine what value1 and value2 are.
  4. Do the same for the encryptit method.
  5. Calling the method self.setDebuggingMessage("debugging string here") will print your debugging string in the debugging textfield. Use this method to help you debug the code. Also, leave in at least one call to self.setDebuggingMessage in the rotation function.

Extra Credit

Create your own encrpytion algorithm (or describe one that was not discussed in class). You do not need to implement the algorithm to get extra credit.

Submitting

Submit the files RsaWindow.py and lab10.txt using assignment name lab10 in eclipse. Don't forget to include your name, NetID, lab section, resources used, and collaborators at the top of allof your files!

 


Adapted from a lab originally created by Albert Meixner and Tammy Bailey.