Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
27 views

CSModule2 Part1

Cryptography is the process of securing communication and information by encoding messages so that only authorized parties can read them. It involves two main techniques - encryption, which converts plain text into cipher text, and decryption, which converts cipher text back to plain text. There are two main categories of cryptography - symmetric key which uses a shared secret key for encryption and decryption, and asymmetric key which uses a public/private key pair. Common cipher techniques in cryptography include traditional ciphers like Caesar and substitution ciphers as well as modern block ciphers. The Vigenere cipher is a polyalphabetic cipher that applies multiple Caesar ciphers using a repeating keyword as the key.

Uploaded by

OK BYE
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

CSModule2 Part1

Cryptography is the process of securing communication and information by encoding messages so that only authorized parties can read them. It involves two main techniques - encryption, which converts plain text into cipher text, and decryption, which converts cipher text back to plain text. There are two main categories of cryptography - symmetric key which uses a shared secret key for encryption and decryption, and asymmetric key which uses a public/private key pair. Common cipher techniques in cryptography include traditional ciphers like Caesar and substitution ciphers as well as modern block ciphers. The Vigenere cipher is a polyalphabetic cipher that applies multiple Caesar ciphers using a repeating keyword as the key.

Uploaded by

OK BYE
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 33

Cryptography

• The process of hiding or coding information so that


only the person a message was intended for can read
it.
• “crypto” means “hidden/secret” and graphy means
“writing”.
• Features – Confidentiality, Integrity, Non-repudiation,
Authentication
• Application of cryptography includes ATM cards,
computer passwords and electronic commerce
Techniques
The data is transferred by applying two techniques
1. Encryption – It is the process of converting simple
data into a coded one. In technical terms, it is the
way of converting the plain text to the cipher text
using a key
2. Decryption - Decryption is a process where the
coded data is converted back to the readable form.
i.e., the cipher text is converted into plain text using
a key at receiver’s end.
Categories of Cryptography
• Symmetric Key Cryptography
– It also referred to as conventional / single-key /
secret-key encryption.
– Sender and receiver share common key

• Asymmetric Key Cryptography


– a pair of keys is used to encrypt and decrypt
information.
– A public key is used for encryption and a private key is
used for decryption.
Types of Ciphers in
Cryptography
What are Ciphers?
• The encryption and decryption algorithms are commonly
known as Ciphers.
• The ciphers are usually public but the keys are kept secret.
• Mainly two types of ciphers – Traditional ciphers and Block
ciphers
Traditional Cipher

• It is the earliest and simplest type of cipher


in which a single character considers as the
unit of data to encrypt.
• This is of two types :
Substitution Cipher
Transposition Cipher
Substitution Cipher technique
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.
Types:-
1. Caesar Cipher
2. Monoalphabetic Ciphers
3. Playfair Cipher
4. Polyalphabetic Ciphers
5. One-Time Pad
Caesar Cipher
• It is one of the earliest known and simplest ciphers.

• It is a type of substitution cipher, in which each letter


of the plaintext is replaced by a letter some fixed
number of positions down the alphabet.

• The method is named after Julius Caesar, who used it


in his private correspondence
In Caesar cipher, the key is numerical, k which
ranges from 1<=k<=26.
For each plain text letter p, the encryption
function to substitute the ciphertext C is
C=E(k, p)=(p + k) mod 26
The decryption function is
P=D(k, C)=(C - k) mod 26 //if (C-k) is

negative then add 26 to it


Example:- A-0 N - 13
Plaintext, p=zebra, key k=3 B-1 O - 14
C(z)=(25+3) mod 26= 28 mod 26
C-2 P - 15
=2=C
C(e)=(4+3) mod 26= 7 mod 26
D–3 Q – 16
=7=H E-4 R -17
C(b)=(1+3) mod 26= 4 mod 26 F -5 S - 18
=4=E G -6 T - 19
C(r)=(17+3) mod 26= 20 mod 26 H-7 U - 20
=20=U
I-8 V -21
C(a)=(0+3) mod 26= 3 mod 26
=3=D
J -9 W - 22
P= Z e b r a K -10 X -23
C=C H E U D L-11 Y -24
M-12 Z -25
• If the ciphertxt is a Caesar cipher, then a brute-
force cryptanalysis is easily performed.
• Three Factors that make Caesar cipher vulnerable
to cryptanalytic attacks are :
1. The encryption and decryption algorithms are known.
2. There are only 26 keys to try.
3. The language of the plaintext is known and easily
recognizable.

Brute-force attack – In this type of attack, the attacker tries every


possible key to decipher the ciphertext.
Monoalphabetic Ciphers
• Problem of Caesar cipher : there are only 26 possible keys are
used to encrypt text. So very easy to brake using brute force
technique.

• Instead of shifting the alphabets by some number,


monoalphabetic ciphers uses some permutation of the letters
in alphabet.

• With 26 letters in alphabet, the possible permutations are 26!


(Factorial of 26) which is equal to 4x1026.
• The sender and the receiver may choose any one of these
possible permutation as a ciphertext alphabet.
• This permutation is the secret key of the scheme.
Example:- Encrypt the plaintext
A B C D E F G H I J K L MN O P Q R S T U V WX Y Z

X U R O K H D A Y V T Q N J E B C Z WF G I L MP S

P=HELLO
C=AKQQE
Playfair Cipher
• Playfair Cipher is a best known multiple-letter
encryption cipher.

• In this digrams in the plaintext as single units and


translates these units into ciphertext digrams.

• The Playfair algorithm is based on the use of a


5 * 5 matrix of letters constructed using a
keyword.
Encryption Technique used in playfair Cipher :

For the encryption process let us consider the following


example:

keyword : MONARCHY

Plaintext : balloon
How the matrix is constructed?
• First you fill the letters of the keyword (minus duplicates)
from left to right and from top to bottom.
• Then filling in the remainder of the matrix with the remaining
letters in alphabetic order.
• The letters I and J count as one letter.
M O N A R
C H Y B D
E F G I/J K
L P Q S T
U V W X Z

• Plaintext is encrypted two letters at a time, according to


some rules
Rule 1:
Plaintext : balloon Repeating plaintext
• To arrange the plaintext as pairs. letters that are in the
ba lx lo on same pair are
separated with a
• To find the ciphertext of plaintext.
filler letter.
M O N A R
C H Y B D Rule 2:
E F G I/J K If both the letters are
L P Q S T in the same column:
Take the letter below
U V W X Z
each one (going back
to the top if at the
• First Pair – ba bottom).
b–I
a–b
Rule 3:
M O N A R
If both the letters are in the
C H Y B D same row: Take the letter to
E F G I/J K the right of each one (going
L P Q S T back to the leftmost if at the
rightmost position).
U V W X Z
• Second pair – lx
l–S
Rule 4:
x–U
• Third pair – lo If neither of the above rules
is true: : form a rectangle
l–P with two letter’s row
o–M direction which intersect
• Fourth pair – on with column direction of
o-N other letter in our pair.
n–A
So ciphertext - IBSUPMNA
Example 2
Plaintext : WORLD
Key: SECURE
S E C U R
A B D F G
H I/J K L M
N O P Q T
V W X Y Z

Plaintext pair – W O RL DX

E W UM KC
Advantages of Playfair Cipher
• Brute force attack does not affect it.
• Cryptanalyze (the process of decoding cipher without knowing
key) is not possible.
• Easy to perform the substitution.

Disdvantages of Playfair Cipher


• Only 25 alphabets are supported.
• It does not support numeric characters.
• Only either upper cases or lower cases are supported.
• The use of special characters (such as blank space, newline,
punctuations, etc.) is prohibited.
• It does not support other languages, except English.
• Encryption of media files is also not supported.
Polyalphabetic Ciphers
Features:-
• A set of monoalphabetic substitution rules

are used.

• A key determines which particular rule is

chosen for a given transformation.


VIGENERE CIPHER
• The best known, and simplest polyalphabetic cipher.
• We can express the Vigenère cipher in the following
manner. Assume,
plaintext letters P = p0, p1, p2,…., pn-1
key, K = k0, k1, k2,…., km-1, where typically m < n.
The sequence of ciphertext letters C = C0, C1, C2, ………, Cn-1 is
calculated as follows:
C = C0, C1, C2, ….. = E(K, P) = (p0 + k0)mod 26, (p1 + k1)mod 26,
(p2 + k2)mod 26 …………….
• The general equation to encrypt the

plaintext is

Ci=(Pi + Kimod26) mod 26

• The general equation to decrypt the

plaintext is

Pi=(Ci - Kimod26) mod 26


Example:-

Plaintext, P= GIVE MONEY


Key =LOCK

• To encrypt a message, a key is needed that


is as long as the message. Usually the key is
a repeating keyword.
A-0
B-1
C-2
Plaintext : G I V E MO N E Y D-3
Key : L OC K L O C K L E-4
F-5
Expressed numerically, we have the following result. G-6
H-7
I-8
Plain Text 6 8 21 4 12 14 13 4 24 J-9
K-10
L-11
Key 11 14 2 10 11 14 2 10 11
M-12
Cipher 17 22 23 14 23 2 15 14 9 N-13
Text O-14
P-15
Q-16
R-17
Ciphertext : R W X O X C P O J S-18
T-19
U-20
V-21
W-22
X-23
Y-24 Z-25
VERNAM CIPHER
• It is used for encrypting alphabetic text.

• Length of the key used for encryption= Length of the


plaintext

• Cipher Text, c= (p+k)


A-0
B-1
Example:- C-2
D-3
E-4
P=HELLO F-5
G-6
K=NCBTA H-7
I-8
Plain Text 7 4 11 11 14 J-9
K-10
L-11
Key 13 2 1 19 0
M-12
Cipher 20 6 12 30 14 N-13
Text= (p+k) O-14
P-15
Q-16
Cipher Text= UGME0 R-17
S-18
T-19
U-20
V-21
W-22
X-23
Y-24 Z-25
One-Time Pad
• One-time pad cipher is a type of Vignere cipher which
includes the following features −
– It is an unbreakable cipher.
– The key is exactly same as the length of message which is
encrypted.
– The key is made up of random symbols.
– As the name suggests, key is used one time only and never used
again for any other message to be encrypted.

• Due to this, encrypted message will be vulnerable to attack


for a cryptanalyst. The key used for a one-time pad cipher is
called pad, as it is printed on pads of paper.
Example -Encryption A-0
B-1
C-2
Plaintext : THIS IS SECRET D-3
Key : XVHE UW NOPGDZ E-4
F-5
Expressed numerically, we have the following result. G-6
H-7
I-8
Plain 19 7 8 18 8 18 18 4 2 17 4 19 J-9
Text K-10
L-11
Key 23 21 7 4 20 22 13 14 15 6 3 25
M-12
Cipher 16 2 15 22 2 14 5 18 17 23 7 18 N-13
Text O-14
P-15
Q-16
R-17
Ciphertext :QCPWCOFSRXHS S-18
T-19
U-20
V-21
W-22
X-23
Y-24 Z-25
Transposition Cipher

• There will be no replacement of characters.

• Here we will rearrange the characters


position. i.e. converts the plain text to cipher
text by performing permutations on the plain
text.
Rail Fence Cipher
• In this, the plaintext is written down as a
sequence of diagonals and then read off as a
sequence of rows.
Example:-
plaintext = welcome to cryptography
To encrypt this with a rail fence of depth 2, we
write the following:
w l o e o r p o r p y
e c m t c y t g a h
ciphertext= wloeorporpyecmtcytgah
Columnar Transposition Cipher
• 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 the columns then becomes the key
to the algorithm.
• Here key must be a numeric value (unique digit
from 0 to 9).
Example:-
Plaintext = welcome to the session
Key = 32451
Let’s take 5 columns an arrange the key and plain text in a row-
wise manner.
3 2 4 5 1
w e l c o
m e t o t
h e s e s
s i o n x
Extra or Dummy character

Then write down the text with the order (ascending) of key value.

To encrypt, start with the column that is labeled 1, in this case column 5. Write down all
the letters in that column. Proceed to column 2, which is labeled 2, then column 1, then
column 3, and 5.

Ciphertext= otsx eeei wmhs ltso coen

You might also like