Presentation is loading. Please wait.

Presentation is loading. Please wait.

LAB#3 CLASSICAL ENCRYPTION CPIT 425. This diagram is taken from Dr.Omaima slides.

Similar presentations


Presentation on theme: "LAB#3 CLASSICAL ENCRYPTION CPIT 425. This diagram is taken from Dr.Omaima slides."— Presentation transcript:

1 LAB#3 CLASSICAL ENCRYPTION CPIT 425

2 This diagram is taken from Dr.Omaima slides

3 Definitions  cipher = an algorithm to transform a normal message into one that is unrecognizable  encrypt (encode) = to convert plaintext to ciphertext using a cipher and a key  decrypt (decode) = to convert ciphertext back into plaintext using a cipher and a key  key = critical information used by the cipher, known only to the sender & receiver

4 Caesar Cipher  Here is a Caesar cipher using the shift parameter 3 as the key: key Plain: ABCDEFGHIJKLMNOPQRSTUVWXYZ Cipher: DEFGHIJKLMNOPQRSTUVWXYZABC Ex: Plaintext: the quick brown fox jumps over the lazy dog Ciphertext: WKH TXLFN EURZQ IRA MXPSV RYHU WKH ODCB GRJ

5 Caesar Cipher  The general Caesar algorithm is: C i = (M i +k) mod 26 M i = (C i -k) mod 26

6 Vigenère Cipher  The general Vigener algorithm is: C i = M i +k i mod 26 M i = C i -k i mod 26

7 Vigenère Cipher  The Vigenère square or Vigenère table

8 Vigenère Cipher  Ex: encrypt the sentence “This is an example of the Vigenere cipher” using the key “vector”: Plaintext:This is an example of the Vigenere cipher Key:vectorvectorvectorvector … Ciphertext:olklwjvrgqodkpghtkcixbuviitxqzklgk

9 Lab Work  Lab work is a Java implementation of the Caesar cipher.  The program reads the input message from the standard input, and outputs the ciphertext on the standard output.  The program reads the key from standard input. It is an integer in the range from 0 to 25 inclusive, and one must use the same key for encryption and decryption.

10 Lab Work What to do:  Using the above ideas and CaesarCipher_lab.java file to Complete the program which used to implement the Caesar Cipher algorithm (when ever you see TO DO:, add your code) Possible improvements:  Modify the code to read the plaintext and write the ciphertext in file.

11 Lab Work (Input/Output)

12 Homework#1 What to do/submit:  Modify the Caesar Cipher code to implement the Substitution (Poly) Cipher.  Write a Java program with a text field, a button and a text area as shown in the following figure. The user should enter the key word in the text field. When the button “Encrypt / Decrypt” is clicked, the text area will display the encrypted and the decrypted text from the input text file(in.txt)  Read the plaintext from a text file(in.txt) and write the ciphertext(encrypted text) to another text file(out1.txt) and then write the text after decryption to another text file (out2.txt).  Read the key word from the standard input.  Submit a soft copy + a report contains the following:  Cover page (student name- ID- CPIT425Lab – HW#1)  Substitution (Poly) Cipher java source code.  Print the output of your code (text files: out1.txt and out2.txt).  Add COMMENTS to your code

13 Homework#1  Read this text from the input file: The Vigenere cipher is a method of encrypting alphabetic text by using a series of different Caesar ciphers based on the letters of a keyword. It is a simple form of polyalphabetic substitution. The Vigenere cipher has been reinvented many times. The method was originally described by Giovan Battista Bellaso. Consequently, many people have tried to implement encryption schemes that are essentially Vigenere ciphers, only to have them broken.

14 Homework Policy  Due date : next lab.  Any late deliveries will NOT be accepted.  In the case of cheating, you will get zero degree.


Download ppt "LAB#3 CLASSICAL ENCRYPTION CPIT 425. This diagram is taken from Dr.Omaima slides."

Similar presentations


Ads by Google