Download presentation
Presentation is loading. Please wait.
Published byJanis Copeland Modified over 8 years ago
1
Information and Computer Security CPIS 312 Lab 1
Classical Encryption TRIGUI Mohamed Salim
2
Lab Outlines Basics of encryption and decryption techniques will be discussed. Each student will try to write simple words on his notebook and encrypt them in some manner. Then he should ask his friend to know what the encrypted letters is. Students should know that there are many algorithms existing for encryption and decryption; we will cover number of them during the semester. Students should understand how Caesar encryption and decryption works, they should implement the algorithm using a suitable programming language.
3
Lab Objectives Students will learn how to work with Monoalphabetic encryption and decryption algorithm and they should select a suitable programming language to implement it.
4
Lab Outcomes In the end of this lab, each student should know what the importance of encryption and decryption techniques is. Students will also learn how to encrypt a plaintext using (Caesar) algorithm; they should build their own programs. Students will be able to work with Monoalphabetic encryption and decryption algorithm and they will be asked to implement it.
5
Traditional symmetric key ciphers
7
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 Substitution cipher = replaces one symbol with another. It can be categorized as either monoalphabetic or polyalphabetic cipher. key = critical information used by the cipher, known only to the sender & receiver
8
Caesar cipher It is the simplest monoalphabetic cipher. Caesar cipher using the shift parameter as the key:
9
Caesar cipher Use the Caesar cipher with key=3 to encrypt the next message: Plaintext: the quick brown fox jumps over the lazy dog Ciphertext: WKH TXLFN EURZQ IRA MXPSV RYHU WKH ODCB GRJ
10
Caesar cipher Use the Caesar cipher with key=15 to encrypt the message “hello” Ciphertext: WTAAD
11
Caesar cipher Use the Caesar cipher with key=15 to decrypt the message “WTAAD” Ciphertext: hello
12
Example public class CaesarCipher { public static void main(String[] args) { String str = "CPIS 312"; int key = 3; String encrypted = encrypt(str, key); System.out.println(encrypted); String decrypted = decrypt(encrypted, key); System.out.println(decrypted); }
13
Example 1 public static String encrypt(String str, int key) { String encrypted = ""; for (int i = 0; i < str.length(); i++) { string c = str.charAt(i); if (Character.isUpperCase(c)) { c = c + (key % 26);} else if (Character.isLowerCase(c)) { c = c + (key % 26);} encrypted += (char) c;} return encrypted;}
14
Example 1 public static String decrypt(String str, int key){ String decrypted = ""; for(int i = 0; i < str.length(); i++) { string c = str.charAt(i); if (Character.isUpperCase(c)) { c = c - (key % 26);} else if (Character.isLowerCase(c)) { c = c - (key % 26);} decrypted += (char) c;} return decrypted;}}
15
Homework Q1. Find the plaintext and the key from the ciphertext: ow sjw klmvqafy afxgjeslagf sfv ugehmlwj kwumjalq
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.