Presentation is loading. Please wait.

Presentation is loading. Please wait.

Information and Computer Security CPIS 312 Lab 3

Similar presentations


Presentation on theme: "Information and Computer Security CPIS 312 Lab 3"— Presentation transcript:

1 Information and Computer Security CPIS 312 Lab 3
Classical Encryption TRIGUI Mohamed Salim

2 Lab Objectives Students will learn how Columnar algorithm works.
Students will try to apply Columnar algorithm practically and they will be able to know how each letter is encrypted using different key. Students will learn how to adjust some parameters of Columnar algorithm, changing key and notice the affects on the cipher text. Students will learn how to work with Transposition encryption and decryption algorithm and they should select a suitable programming language to implement it.

3 Lab Outcomes At the end of this lab, students will be able to work with Columnar algorithm by testing it practically during the lab. Students will be able to work with Transposition encryption and decryption algorithm and they will be asked to implement it.

4 Traditional symmetric key ciphers

5

6 One-Time Pads

7 One-Time Pads To decrypt: (Ci – Ki) mod 26
Choose a random bit string as the key Convert the plaintext into a bit string Compute the XOR of these two strings, bit by bit To decrypt: (Ci – Ki) mod 26 Note on rules of mod on negative number: “The mod function is defined as the amount by which a number exceeds the largest integer multiple of the divisor that is not greater than that number” ( Modula op always return non-negative number E.g., (19-76) mod 26 = (-57) mod 26 = (-78+21) mod 26 = 21

8 One-Time Pads Plaintext V E R N A M C I P H Numeric Equivalent 21 4 17
13 12 2 8 15 7 + Random Number 76 48 16 82 44 3 58 11 60 5 47 88 = Sum 97 52 33 95 19 75 51 105 = mod 26 18 23 25 1 Ciphertext t a h r s p i x m z b Ciphertext t a h r s p i x m z b Numeric Equivalent 19 7 17 18 15 8 23 12 25 1 - One-time pad 76 48 16 82 44 3 58 11 60 5 47 88 = Difference -57 -48 -9 -65 -26 -50 -37 -22 -87 = mod 26 21 4 13 2 Plaintext V E R N A M C I P H

9 Columnar cipher is a more complex transposition
write letters of message out in rows over a specified number of columns Number of columns = key length then reorder the columns according to some key before reading off the rows

10 Columnar cipher Plaintext (M)= ATTACK POSTPONED UNTIL TWO AM Key: Ciphertext: TTNAAPTMTSUOAODWCOIXKNLYPETZ 7 6 5 2 1 3 4 Column Out p k c a t A Plaintext e n o s l i u d x m w

11 Columnar cipher Plaintext (M)= THIS IS A MESSAGE TO SHOW HOW COLUMNAR WORKS Key: Ciphertext: IETHUO SAHCAS TAGOOR SSOOMR HMEWLW ISSWNK 2 6 4 1 5 3 Column Out s i h t Plaintext a e m o g c w n u l k r

12 Columnar cipher Ciphertext(C): EVLNX ACDTX ESEAX ROFOX DEECX WIREE Key: Plaintext (M): WE ARE DISCOVERED FLEE AT ONCE 5 1 4 2 3 6 Column Out d e r a w Ciphertext v o c s i l f n t x

13 Example import java.io.*; class encryptCeasar{ public static void main(String[] args){ try{ FileReader fr = new FileReader(args[0]); BufferedReader br = new BufferedReader(fr); String plaintext = br.readLine(); plaintext = plaintext.toUpperCase(); int shiftKey = Integer.parseInt(args[1]); shiftKey = shiftKey % 26;

14 Example String cipherText = ""; for (int i=0; i<plaintext.length(); i++){ int asciiValue = (int) plaintext.charAt(i); if (asciiValue < 65 || asciiValue > 90){ cipherText += plaintext.charAt(i); Continue;} int basicValue = asciiValue - 65; int newAsciiValue = 65 + ((basicValue + shiftKey) % 26) ; cipherText += (char) newAsciiValue;} System.out.print(cipherText);} catch(Exception e){e.printStackTrace();}} }

15 We are studying information and computer security
Homework Encrypt the following plaintext using Columnar transposition: We are studying information and computer security Use your first name as keyword


Download ppt "Information and Computer Security CPIS 312 Lab 3"

Similar presentations


Ads by Google