Unit 2 Cryptography - BSc IT 5 PDF
Document Details
Uploaded by ViewableSwan
Marwadi University
Tags
Summary
This document provides a lecture on classical encryption techniques, including Ceasar and Playfair ciphers, and transposition ciphers. It covers basic substitution and transposition techniques and provides examples.
Full Transcript
Unit 2 z z CLASSICAL ENCRYPTION TECHNIQUES ( classical cryptography) There are two basic building blocks of classical encryption techniques: (i) substitution (ii) transposition. z SUBSTITUTION TECHNIQUES A substituti...
Unit 2 z z CLASSICAL ENCRYPTION TECHNIQUES ( classical cryptography) There are two basic building blocks of classical encryption techniques: (i) substitution (ii) transposition. z SUBSTITUTION TECHNIQUES A substitution technique is one in which the letters of plaintext are replaced by other letters or by numbers or symbols. If the plaintext is viewed as a sequence of bits, then substitution involves replacing plaintext bit patterns with cipher text bit patterns. z (i) Ceaser cipher or Shift cipher The Caesar Cipher technique is one of the earliest and simplest method of encryption technique. It’s simply a type of substitution cipher, i.e., each letter of a given text is replaced by a letter some fixed number of positions up/down the alphabet. For example with a shift of 1, A would be replaced by B, B would become C, and so on. The method is apparently named after Julius Caesar. Thus to cipher a given text we need an integer value, known as shift which indicates the number of position each letter of the text has been moved down. The encryption can be represented using modular arithmetic by first transforming the letters into numbers, according to the scheme, A = 0, B = 1,…, Z = 25. Encryption of a letter by a shift n can be described mathematically as. z Caesar cipher involves replacing each letter of the alphabet with the letter standing 3 places further down the alphabet. Example1 : Plain text : amp Cipher text : dps Example2 : Plain text : PAY MORE MONEY (shift=3) Cipher text : SDB PRUH PRQHB Note that the alphabet is wrapped around, so that letter following “z‟ is “a‟. For each plaintext letter p, substitute the cipher text letter c such that C = E(p) = (p+3) mod 26 For each cipher letter c, subtitute the plain text letter p such that z A shift may be any amount, so that general Caesar algorithm is E (Plain text) = (p+k) mod 26 = cipher text (C ) Where k takes on a value in the range 1 to 25. The decryption algorithm is simply D (Cipher text) = (c-k) mod 26 = Plain text (P ) Demo : https://www.mymathtables.com/calculator/digital/caesar-cipher-encript- decript-converter.html z (ii) Playfair cipher The best known multiple letter encryption cipher is the Playfair, which treats diagrams in the plaintext as single units and translates these units into cipher text diagrams. The Playfair cipher was the first practical digraph substitution cipher The Playfair algorithm is based on the use of 5x5 matrix of letters constructed using a keyword. Let the keyword be „monarchy‟. The matrix is constructed by filling in the letters of the keyword (minus duplicates) from left to right and from top to bottom, and then filling in the remainder of the matrix with the remaining letters in alphabetical order. The letter „i‟ and „j‟ count as one letter. Plaintext is encrypted two letters at a time According to the following rules: z The key is "monarchy" Thus the initial entires are 'm', 'o', 'n', 'a', 'r', 'c', ‘h', 'y' followed by remaining characters of a-z(except 'j') in that order. z Cont.. The plaintext is split into pairs of two letters (digraphs). If there is an odd number of letters, x is added to the last letter. For example: PlainText: "instruments" After Split: 'in' 'st' 'ru' 'me' 'nt' ‘sz’ z Rules for Encryption: Rule-1: If both the letters are in the same column: Take the letter below each one (going back to the top if at the bottom). For example: Diagraph: "me" Encrypted Text: cl Encryption: m -> c e -> l z Rule-2: If both the letters are in the same row: Take the letter to the right of each one (going back to the leftmost if at the rightmost position).For example: For example Diagraph: "st" Encrypted Text: tl Encryption: s -> t t -> l z Rule-3: If neither of the above rules is true: Form a rectangle with the two letters and take the letters on the horizontal opposite corner of the rectangle. For example: Diagraph: "nt" Encrypted Text: rq Encryption: n -> r t -> q For example: z Plain Text: "instruments" A After Split: 'in’ 'st’ 'ru’ 'me’ 'nt’ ‘sz’ Encrypted Text: ga tl mz cl rq tx z Example-2 Plaintext = meet me at the school house Splitting two letters as a unit => me et me at th es ch ox ol ho us ex Corresponding cipher text => CL KL CL RS PD IL HY AV MP FH XL IU z TRANSPOSITION TECHNIQUES All the techniques examined so far involve the substitution of a cipher text symbol for a plaintext symbol. Performing some sort of permutation on plaintext letters. Changing arrangement of letters. Example : NAME--->MEAN key : 3421 Security is less, can be recognized easily. Multiple transposition can be done to make it more secure. This technique is referred to as a transposition cipher. z Rail fence cipher The rail fence cipher (sometimes called zigzag cipher) is a transposition cipher that jumbles up the order of the letters of a message using a basic algorithm. The rail fence cipher works by writing your message on alternate lines across the page, and then reading off each line in turn. z For example, let’s consider the plaintext “This is a secret message” To encode this message we will first write over two lines (the “rails of the fence”) as follows: Note that all white spaces have been removed from the plain text. The ciphertext is then read off by writing the top row first, followed by the bottom row z More complex Rail Fence Ciphers have more “rails”. For instance instead of writing the code over two lines (“rails”) you can write over three or four or more lines. The number of lines used in a Rail Fence Cipher is called the key A Rail Fence Cipher with 3 “rails” (Key = 3) : z A Rail Fence Cipher with 4 “rails” (Key = 4) z Row Transposition Ciphers A more complex scheme is to write the message in a rectangle, row by row, and read the message off, column by column, but permute the order of the columns. The order of columns then becomes the key of the algorithm. Plain text : attack postponed until two am z Thus, in this example, the key is 4312567.To encrypt, start with the column that is labeled 1, in this case column 3.Write down all the letters in that column. Proceed to column 4, which is labeled 2, then column 2, then column 1, then columns 5, 6, and 7. A pure transposition cipher is easily recognized because it has the same letter frequencies as the original plaintext. The transposition cipher can be made significantly more secure by performing more than one stage of transposition. Thus, if the foregoing message is re-encrypted using the same algorithm, z Cont.. A pure transposition cipher is easily recognized because it has the same letter frequencies as the original plaintext. The transposition cipher can be made significantly more secure by performing more than one stage of transposition. The result is more complex permutation that is not easily reconstructed. z Thank You z