Transcript M i

LAB#3
CLASSICAL ENCRYPTION
CPIT 425
Cryptosystem (Ciphers)
Symmetric or Conventional or Secret Key
Classical
Substitution
(Stream)
Asymmetric or Public Key
(RSA, ElGamal, Rabin)
Modern
(DES, Triple DES, AES)
(Block)
Permutation or Transposition
(Block)
Monoalphabetic
(Caesar)
Polyalphabetic
(Vigener)
One-time Pad
This diagram is
taken
from Dr.Omaima
slides
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

Caesar Cipher

Here is a Caesar cipher using the shift parameter 3 as the
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
Caesar Cipher

The general Caesar algorithm is:
Ci= (Mi+k) mod 26
Mi= (Ci-k) mod 26
Vigenère Cipher

The general Vigener algorithm is:
Ci= Mi+ki mod 26
Mi= Ci-ki mod 26
Vigenère Cipher

The Vigenère square or Vigenère table
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
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.
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.
Lab Work (Input/Output)
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
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.

Homework Policy
Due date : next lab.
 Any late deliveries will NOT be accepted.
 In the case of cheating, you will get zero
degree.
