SlideShare une entreprise Scribd logo
1  sur  24
Télécharger pour lire hors ligne
Computer Security & Networks
Dr. Saif Kassim Alfraije Page 1
Polyalphabetic Cipher
Leon Battista invented the Polyalphabetic Substitution Cipher in year 1568.
“Poly means Many in Greek language”. This method uses a mixed alphabet to
encrypt a message. The Enigma machine is more complex but still fundamentally a
polyalphabetic substitution cipher.
In polyalphabetic substitution, each occurrence of a character may have a different
substitute. The Polyalphabetic Cipher was adapted as a twist on the standard
Caesar cipher to reduce the effectiveness of frequency analysis on the ciphertext.
The polyalphabetic cipher uses a text string (for example, a word) as a key, which
is then used for doing a number of shifts on the plaintext.
Polyalphabetic Cipher Types
A. Vigenère Cipher
B. One Time Pad Cipher
C. Playfair Cipher
D. Hill Cipher
Vigenere cipher
One such cipher is the famous Vigenere cipher, the Vigenere cipher uses
the power of 26 possible shift ciphers. A tool that was used for the Vigenère
Cipher was a (code wheel) or (Keyword). Vigenere cipher shifts the characters in a
string by some places. Now those some places are determined by the characters
that are present in the key string.
P=P1P2P3…… C=C1C2C3…….. k=[(K1,K2,….. , KM), (K1,K2,….. , KM),..]
Encryption : Ci = Pi + Ki Decryption : Pi = Ci - Ki
Computer Security & Networks
Dr. Saif Kassim Alfraije Page 2
Example
Plain Text: “Computer Science”. Key = Security, Cipher Text?
 Encode plain text.
 Write key under coded plaintext, repeating as many times as necessary.
 Encode key.
 Add key character code to corresponding plain text code (mod 26).
 Decoding of resulting integer is Ciphertext.
 Note: If (Pencoding + Kencoding) >= 26 then - 26
Answer (Encryption)
Plain text C O M P U T E R S C I E N C E
Pencoding 2 14 12 15 20 19 4 17 18 2 8 4 13 2 4
Key S E C U R I T Y S E C U R I T
Kencoding 18 4 2 20 17 8 19 24 18 4 2 20 17 8 19
Cipher Code 20 18 14 9 11 1 23 15 10 6 10 24 4 10 23
Cipher text U S O J L B X P K G K Y E K X
+
Computer Security & Networks
Dr. Saif Kassim Alfraije Page 3
Decryption
Ciphertext = USOJLBXPKGKYEKX , Key = Security . Plaintext ??
Cipher text U S O J L B X P K G K Y E K X
Cipher Code 20 18 14 9 11 1 23 15 10 6 10 24 4 10 23
Key S E C U R I T Y S E C U R I T
Kencoding 18 4 2 20 17 8 19 24 18 4 2 20 17 8 19
Pencoding 2 14 12 15 20 19 4 17 18 2 8 4 13 2 4
Plain text C O M P U T E R S C I E N C E
-
9 – 20 = – 11 : 26 – 11 = 15
Computer Security & Networks
Dr. Saif Kassim Alfraije Page 4
Build Program
1. Add a three label control on the form. Set the first Text property to Plain
text , second label set to Key and third to Cipher text .
2. Add three text box controls as shown.
o Name the first text box control PTtxt
o Name the second text box control Keytxt
o Name the third text box control CTtxt
3. Add two button controls as shown.
o Name the first button control Encryption
o Name the second button control Decryption
Computer Security & Networks
Dr. Saif Kassim Alfraije Page 5
Program Coding
 Double-click the Encryption control. And write follow code.
 Double-click the Decryption control. And write follow code.
 Now you can write class VigenereCipher that contain two function Encrypt
For return Cipher text and Decrypt for return Result Plain to the end user
Depending on the key type string , this function will receive 2 parameters
when you click button Enc or Dec :
 Plain text
 Key Secret
Private Sub Encbtn_Click(sender As Object, e As EventArgs) Handles Encbtn.Click
CTtxt.Text = VigenereCipher.Encrypt(PTtxt.Text, Keytxt.Text)
End Sub
Private Sub Decbtn_Click(sender As Object, e As EventArgs) Handles Decbtn.Click
CTtxt.Text = VigenereCipher.Decrypt(PTtxt.Text, Keytxt.Text)
End Sub
Computer Security & Networks
Dr. Saif Kassim Alfraije Page 6
Public Class VigenereCipher
Public Shared Function Encrypt(ByVal plainTxt As String, ByVal key As
String)
Dim encryptedText As String = ""
For i As Integer = 1 To cipherTxt.Length
Dim temp As Integer = AscW(GetChar(cipherTxt, i)) +
AscW(GetChar(key, i Mod key.Length + 1))
encryptedText += ChrW(temp)
Next
Return encryptedText
End Function
Public Shared Function Decrypt(ByVal cipherTxt As String, ByVal key
As String)
Dim decryptedText As String = ""
For i As Integer = 1 To cipherTxt.Length
Dim temp As Integer = AscW(GetChar(cipherTxt, i)) -
AscW(GetChar(key, i Mod key.Length + 1))
decryptedText += ChrW(temp)
Next
Return decryptedText
End Function
End Class
Computer Security & Networks
Dr. Saif Kassim Alfraije Page 7
One Time Pad Cipher
known as Vernam Cipher is implemented using a random set of non
repeating characters as the Key. The rest of process is same as the Vigenère cipher.
The sender uses each key letter on the pad to encrypt exactly one plaintext
character. Encryption is the addition modulo 26 of the plaintext character and the
one-time pad key character
(Pencoding + Kencoding) >= 26 then - 26
Example: ( Encryption )
Plaintext: “ HOW ARE YOU ’’ Key = NCBTZQARX Ciphertext: ?
Plain text H O W A R E Y O U
Pencoding 7 14 22 0 17 4 24 14 20
Key N C B T Z Q A R X
Kencoding 13 2 1 19 25 16 0 17 23
Cipher Code 20 16 23 19 16 20 24 5 17
Cipher text U Q X T Q U Y F R
+
Computer Security & Networks
Dr. Saif Kassim Alfraije Page 8
(Decryption)
Cipher text U Q X T Q U Y F R
Cipher Code 20 16 23 19 16 20 24 5 17
Key N C B T Z Q A R X
Kencoding 13 2 1 19 25 16 0 17 23
Pencoding 7 14 22 0 17 4 24 14 20
Plain text H O W A R E Y O U
-
16 – 25 = – 9 26 – 9 = 17
Computer Security & Networks
Dr. Saif Kassim Alfraije Page 9
Playfair Cipher
The Playfair cipher encrypts pairs of letters, instead of single letters. This is
significantly harder to break. Each plaintext letter is replaced by a diagram in this
cipher.
 User chooses a keyword and puts it in the cells of a 5 x 5 matrix.
 Letter I and J always stay in one cell .
 Duplicate letters appear only once.
 Number of diagrams is 26 x 26 = 676.
 To encrypt a message, one would break the message into groups of 2
letters. If there is a dangling letter at the end, we add an X. For
example. "Secret Message" becomes "SE CR ET ME SS AG EX".
We now take each group and find them out on the table. we apply the
following rules, in order.
Playfair Cipher Rules
1. If the digraph consists of the same letter twice (or there is only one
letter left by itself at the end of the plaintext) then insert the letter "X"
between the same letters (or at the end), and then continue with the
rest of the steps.
2. If the two letters appear on the same row in the square, then replace
each letter by the letter immediately to the right of it in the square
(cycling round to the left hand side if necessary).
3. If the two letters appear in the same column in the square, then
replace each letter by the letter immediately below it in the square
(cycling round to the top of the square if necessary).
4. Otherwise, form the rectangle for which the two plaintext letters are
two opposite corners. Then replace each plaintext letter with the letter
that forms the other corner of the rectangle that lies on the
same row as that plaintext letter (being careful to maintain the order).
Computer Security & Networks
Dr. Saif Kassim Alfraije Page 10
Example
Plain text = Hide the gold in the tree stump , key = playfair example ,
Cipher text ??
Firstly we must generate the Polybius Square that we are going to use. We
do this by setting out a 5x5 grid, and filling it with the alphabet, starting with the
letters of the keyphrase, and ignoring any letters we already have in the square. We
are also going to combine "I" and "J" in the square.
We must now split the plaintext into digraphs, and split up any double letter
digraphs by inserting an "x" between them. The first image below shows the initial
digraph split of the plaintext, and the second image displays how we split up the
"ee" into "ex" and "es". In this case, when we insert this extra "x", we no longer
need to have one at the end of the plaintext.
HI DE TH EG OL DI NT HE TR EE ST UM P
P L A Y F
I R E X M
B C D G H
K N O Q S
T U V W Z
HI DE TH EG OL DI NT HE TR EX ES TU MP
Computer Security & Networks
Dr. Saif Kassim Alfraije Page 11
We now take each digraph in turn and apply rule 2, 3 or 4 as necessary. Each
step is show below with a visual representation of what is done for each digraph.
Computer Security & Networks
Dr. Saif Kassim Alfraije Page 12
Computer Security & Networks
Dr. Saif Kassim Alfraije Page 13
Computer Security & Networks
Dr. Saif Kassim Alfraije Page 14
Computer Security & Networks
Dr. Saif Kassim Alfraije Page 15
We can now take each of the ciphertext digraphs that we produced and put
them all together.
BM OD ZB XD NA BE KU DM UI XM MO UV IF
Homework
Decrypt the Cipher text = BMODZBXDNABEKUDMUIXMMOUVIF .
When the key = playfair example
Computer Security & Networks
Dr. Saif Kassim Alfraije Page 16
Hill Cipher
The Hill Cipher was invented by Lester S. Hill in 1929, and like the
other Digraphic Ciphersit acts on groups of letters. Unlike the others though it is
extendable to work on different sized blocks of letters. So, technically it is a
polygraphic substitution cipher, as it can work on digraphs, trigraphs (3 letter
blocks) or theoretically any sized blocks.
The Hill Cipher uses an area of mathematics called Linear Algebra, and in
particular requires the user to have an elementary understanding of matrices. It also
make use of Modulo Arithmetic (like the Affine Cipher). Because of this, the
cipher has a significantly more mathematical nature than some of the others.
However, it is this nature that allows it to act (relatively) easily on larger blocks of
letters.
Encryption
To encrypt a message using the Hill Cipher we must first turn our keyword into a
key matrix (a 2 x 2 matrix for working with digraphs, a 3 x 3 matrix for working
with trigraphs, etc). We also turn the plaintext into digraphs (or trigraphs) and each
of these into a column vector. We then perform matrix multiplication modulo the
length of the alphabet (i.e. 26) on each vector. These vectors are then converted
back into letters to produce the ciphertext.
2 x 2 Example
We shall encrypt the plaintext message "short example" using the
keyword hill and a 2 x 2 matrix. The first step is to turn the keyword into a matrix.
With the keyword in a matrix, we need to convert this into a key matrix.
Computer Security & Networks
Dr. Saif Kassim Alfraije Page 17
We now split the plaintext into digraphs, and write these as column vectors. That
is, in the first column vector we write the first plaintext letter at the top, and the
second letter at the bottom
Now we must convert the plaintext column vectors in the same way that we
converted the keyword into the key matrix.
Now we must perform some matrix multiplication. We multiply the key matrix by
each column vector in turn.
To perform matrix multiplication we "combine" the top row of the key matrix with
the column vector to get the top element of the resulting column vector. We then
"combine" the bottom row of the key matrix with the column vector to get the
bottom element of the resulting column vector.
Computer Security & Networks
Dr. Saif Kassim Alfraije Page 18
Next we have to take each of these numbers, in our resultant column vector,
modulo 26 (remember that means divide by 26 and take the remainder).
Finally we have to convert these numbers back to letters, so 0 becomes "A" and 15
becomes "P", and our first two letters of the ciphertext are "AP".
Computer Security & Networks
Dr. Saif Kassim Alfraije Page 19
Encryption process of the first digraph
Computer Security & Networks
Dr. Saif Kassim Alfraije Page 20
Computer Security & Networks
Dr. Saif Kassim Alfraije Page 21
Computer Security & Networks
Dr. Saif Kassim Alfraije Page 22
Decryption
To decrypt a ciphertext encoded using the Hill Cipher, we must find the inverse
matrix. Once we have the inverse matrix, the process is the same as encrypting.
In general, to find the inverse of the key matrix, we perform the calculation below,
where Kis the key matrix, d is the determinant of the key matrix and adj(K) is the
adjugate matrix of K.
2 x 2 Example
We shall decrypt the example above, so we are using the keyword hill and our
ciphertext is "APADJ TFTWLFJ".
Step 1 - Find the Multiplicative Inverse of the Determinant
The determinant is a number that relates directly to the entries of the matrix. It is
found by multiplying the top left number by the bottom right number and
subtracting from this the product of the top right number and the bottom left
number.
Computer Security & Networks
Dr. Saif Kassim Alfraije Page 23
We now have to find the multiplicative inverse of the determinant working
modulo 26. That is, the number between 1 and 25 that gives an answer of 1 when
we multiply it by the determinant. So, in this case, we are looking for the number
that we need to multiply 15 by to get an answer of 1 modulo 26.
So the multiplicative inverse of the determinant modulo 26 is 7. We shall need this
number later.
Step 2 - Find the Adjugate Matrix
The adjugate matrix is a matrix of the same size as the original. For a 2 x 2 matrix,
this is fairly straightforward as it is just moving the elements to different positions
and changing a couple of signs.
Computer Security & Networks
Dr. Saif Kassim Alfraije Page 24
Again, once we have these values we will need to take each of them modulo 26 (in
particular, we need to add 26 to the negative values to get a number between 0 and
25. For our example we get the matrix below.
Step 3 - Multiply the Multiplicative Inverse of the Determinant by the
Adjugate Matrix
To get the inverse key matrix, we now multiply the inverse determinant (that was 7
in our case) from step 1 by each of the elements of the adjugate matrix from step 2.
Then we take each of these answers modulo 26.
Now we have the inverse key matrix, we have to convert the ciphertext into
column vectors and multiply the inverse matrix by each column vector in turn, take
the results modulo 26 and convert these back into letters to get the plaintext.

Contenu connexe

Tendances (20)

Topic5 advanced encryption standard (aes)
Topic5 advanced encryption standard (aes)Topic5 advanced encryption standard (aes)
Topic5 advanced encryption standard (aes)
 
Ethical hacking presentation
Ethical hacking presentationEthical hacking presentation
Ethical hacking presentation
 
Cryptography
CryptographyCryptography
Cryptography
 
Cryptography - 101
Cryptography - 101Cryptography - 101
Cryptography - 101
 
Crytography
CrytographyCrytography
Crytography
 
Module 8 System Hacking
Module 8   System HackingModule 8   System Hacking
Module 8 System Hacking
 
Ethical Hacking
Ethical HackingEthical Hacking
Ethical Hacking
 
Unit 7 : Network Security
Unit 7 : Network SecurityUnit 7 : Network Security
Unit 7 : Network Security
 
Cryptography with caesar Cipher
Cryptography with caesar CipherCryptography with caesar Cipher
Cryptography with caesar Cipher
 
Ch03
Ch03Ch03
Ch03
 
Number Theory In Cryptography
Number Theory In CryptographyNumber Theory In Cryptography
Number Theory In Cryptography
 
Ethical hacking and social engineering
Ethical hacking and social engineeringEthical hacking and social engineering
Ethical hacking and social engineering
 
Will Internet of Things (IoT) be secure enough?
Will Internet of Things (IoT) be secure enough? Will Internet of Things (IoT) be secure enough?
Will Internet of Things (IoT) be secure enough?
 
IoT security (Internet of Things)
IoT security (Internet of Things)IoT security (Internet of Things)
IoT security (Internet of Things)
 
Cryptography Fundamentals
Cryptography FundamentalsCryptography Fundamentals
Cryptography Fundamentals
 
Advanced encryption standard (aes)
Advanced encryption standard (aes)Advanced encryption standard (aes)
Advanced encryption standard (aes)
 
Application layer security protocol
Application layer security protocolApplication layer security protocol
Application layer security protocol
 
Introduction to Cryptography
Introduction to CryptographyIntroduction to Cryptography
Introduction to Cryptography
 
Cryptography
Cryptography Cryptography
Cryptography
 
Cisco cybersecurity essentials chapter 8
Cisco cybersecurity essentials chapter 8Cisco cybersecurity essentials chapter 8
Cisco cybersecurity essentials chapter 8
 

Similaire à Computer Security (Cryptography) Ch03

Encrypted message transmitter on public network
Encrypted message transmitter on public networkEncrypted message transmitter on public network
Encrypted message transmitter on public networkRowshina Nikzad
 
Basic Encryption Decryption Chapter 2
Basic Encryption Decryption Chapter 2Basic Encryption Decryption Chapter 2
Basic Encryption Decryption Chapter 2AfiqEfendy Zaen
 
Computer Security (Cryptography) Ch02
Computer Security (Cryptography) Ch02Computer Security (Cryptography) Ch02
Computer Security (Cryptography) Ch02Saif Kassim
 
Classical encryption techniques
Classical encryption techniquesClassical encryption techniques
Classical encryption techniquesJanani S
 
Cyber Security Part-2.pptx
Cyber Security Part-2.pptxCyber Security Part-2.pptx
Cyber Security Part-2.pptxRavikumarVadana
 
classicalencryptiontechniques.ppt
classicalencryptiontechniques.pptclassicalencryptiontechniques.ppt
classicalencryptiontechniques.pptutsavkakkad1
 
M.Sridevi II-M.Sc (computer science)
M.Sridevi II-M.Sc (computer science)M.Sridevi II-M.Sc (computer science)
M.Sridevi II-M.Sc (computer science)SrideviM4
 
Cryptography (Revised Edition)
Cryptography (Revised Edition)Cryptography (Revised Edition)
Cryptography (Revised Edition)Somaditya Basak
 
Understanding the History of EncryptionUnderstanding the
Understanding the History of EncryptionUnderstanding theUnderstanding the History of EncryptionUnderstanding the
Understanding the History of EncryptionUnderstanding thecorbing9ttj
 
CryptX '22 W1 Release (1).pptx
CryptX '22 W1 Release (1).pptxCryptX '22 W1 Release (1).pptx
CryptX '22 W1 Release (1).pptxBhavikaGianey
 
Cypher technique
Cypher techniqueCypher technique
Cypher techniqueZubair CH
 
Secret key cryptography
Secret key cryptographySecret key cryptography
Secret key cryptographyPrabhat Goel
 
Amanda Sopkin - Computational Randomness: Creating Chaos in an Ordered Machin...
Amanda Sopkin - Computational Randomness: Creating Chaos in an Ordered Machin...Amanda Sopkin - Computational Randomness: Creating Chaos in an Ordered Machin...
Amanda Sopkin - Computational Randomness: Creating Chaos in an Ordered Machin...Codemotion
 

Similaire à Computer Security (Cryptography) Ch03 (20)

Encrypted message transmitter on public network
Encrypted message transmitter on public networkEncrypted message transmitter on public network
Encrypted message transmitter on public network
 
Basic Encryption Decryption Chapter 2
Basic Encryption Decryption Chapter 2Basic Encryption Decryption Chapter 2
Basic Encryption Decryption Chapter 2
 
Ch02...1
Ch02...1Ch02...1
Ch02...1
 
Computer Security (Cryptography) Ch02
Computer Security (Cryptography) Ch02Computer Security (Cryptography) Ch02
Computer Security (Cryptography) Ch02
 
Classical encryption techniques
Classical encryption techniquesClassical encryption techniques
Classical encryption techniques
 
Cryptography.ppt
Cryptography.pptCryptography.ppt
Cryptography.ppt
 
Cyber Security Part-2.pptx
Cyber Security Part-2.pptxCyber Security Part-2.pptx
Cyber Security Part-2.pptx
 
classicalencryptiontechniques.ppt
classicalencryptiontechniques.pptclassicalencryptiontechniques.ppt
classicalencryptiontechniques.ppt
 
M.Sridevi II-M.Sc (computer science)
M.Sridevi II-M.Sc (computer science)M.Sridevi II-M.Sc (computer science)
M.Sridevi II-M.Sc (computer science)
 
Cryptography (Revised Edition)
Cryptography (Revised Edition)Cryptography (Revised Edition)
Cryptography (Revised Edition)
 
unit 2.ppt
unit 2.pptunit 2.ppt
unit 2.ppt
 
Understanding the History of EncryptionUnderstanding the
Understanding the History of EncryptionUnderstanding theUnderstanding the History of EncryptionUnderstanding the
Understanding the History of EncryptionUnderstanding the
 
Crypto
CryptoCrypto
Crypto
 
Edward Schaefer
Edward SchaeferEdward Schaefer
Edward Schaefer
 
CryptX '22 W1 Release (1).pptx
CryptX '22 W1 Release (1).pptxCryptX '22 W1 Release (1).pptx
CryptX '22 W1 Release (1).pptx
 
Cypher technique
Cypher techniqueCypher technique
Cypher technique
 
Secret key cryptography
Secret key cryptographySecret key cryptography
Secret key cryptography
 
Amanda Sopkin - Computational Randomness: Creating Chaos in an Ordered Machin...
Amanda Sopkin - Computational Randomness: Creating Chaos in an Ordered Machin...Amanda Sopkin - Computational Randomness: Creating Chaos in an Ordered Machin...
Amanda Sopkin - Computational Randomness: Creating Chaos in an Ordered Machin...
 
Network security CS2
Network security CS2Network security CS2
Network security CS2
 
IS LEC 6.pdf
IS LEC 6.pdfIS LEC 6.pdf
IS LEC 6.pdf
 

Dernier

Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...Pooja Nehwal
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 

Dernier (20)

Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 

Computer Security (Cryptography) Ch03

  • 1. Computer Security & Networks Dr. Saif Kassim Alfraije Page 1 Polyalphabetic Cipher Leon Battista invented the Polyalphabetic Substitution Cipher in year 1568. “Poly means Many in Greek language”. This method uses a mixed alphabet to encrypt a message. The Enigma machine is more complex but still fundamentally a polyalphabetic substitution cipher. In polyalphabetic substitution, each occurrence of a character may have a different substitute. The Polyalphabetic Cipher was adapted as a twist on the standard Caesar cipher to reduce the effectiveness of frequency analysis on the ciphertext. The polyalphabetic cipher uses a text string (for example, a word) as a key, which is then used for doing a number of shifts on the plaintext. Polyalphabetic Cipher Types A. Vigenère Cipher B. One Time Pad Cipher C. Playfair Cipher D. Hill Cipher Vigenere cipher One such cipher is the famous Vigenere cipher, the Vigenere cipher uses the power of 26 possible shift ciphers. A tool that was used for the Vigenère Cipher was a (code wheel) or (Keyword). Vigenere cipher shifts the characters in a string by some places. Now those some places are determined by the characters that are present in the key string. P=P1P2P3…… C=C1C2C3…….. k=[(K1,K2,….. , KM), (K1,K2,….. , KM),..] Encryption : Ci = Pi + Ki Decryption : Pi = Ci - Ki
  • 2. Computer Security & Networks Dr. Saif Kassim Alfraije Page 2 Example Plain Text: “Computer Science”. Key = Security, Cipher Text?  Encode plain text.  Write key under coded plaintext, repeating as many times as necessary.  Encode key.  Add key character code to corresponding plain text code (mod 26).  Decoding of resulting integer is Ciphertext.  Note: If (Pencoding + Kencoding) >= 26 then - 26 Answer (Encryption) Plain text C O M P U T E R S C I E N C E Pencoding 2 14 12 15 20 19 4 17 18 2 8 4 13 2 4 Key S E C U R I T Y S E C U R I T Kencoding 18 4 2 20 17 8 19 24 18 4 2 20 17 8 19 Cipher Code 20 18 14 9 11 1 23 15 10 6 10 24 4 10 23 Cipher text U S O J L B X P K G K Y E K X +
  • 3. Computer Security & Networks Dr. Saif Kassim Alfraije Page 3 Decryption Ciphertext = USOJLBXPKGKYEKX , Key = Security . Plaintext ?? Cipher text U S O J L B X P K G K Y E K X Cipher Code 20 18 14 9 11 1 23 15 10 6 10 24 4 10 23 Key S E C U R I T Y S E C U R I T Kencoding 18 4 2 20 17 8 19 24 18 4 2 20 17 8 19 Pencoding 2 14 12 15 20 19 4 17 18 2 8 4 13 2 4 Plain text C O M P U T E R S C I E N C E - 9 – 20 = – 11 : 26 – 11 = 15
  • 4. Computer Security & Networks Dr. Saif Kassim Alfraije Page 4 Build Program 1. Add a three label control on the form. Set the first Text property to Plain text , second label set to Key and third to Cipher text . 2. Add three text box controls as shown. o Name the first text box control PTtxt o Name the second text box control Keytxt o Name the third text box control CTtxt 3. Add two button controls as shown. o Name the first button control Encryption o Name the second button control Decryption
  • 5. Computer Security & Networks Dr. Saif Kassim Alfraije Page 5 Program Coding  Double-click the Encryption control. And write follow code.  Double-click the Decryption control. And write follow code.  Now you can write class VigenereCipher that contain two function Encrypt For return Cipher text and Decrypt for return Result Plain to the end user Depending on the key type string , this function will receive 2 parameters when you click button Enc or Dec :  Plain text  Key Secret Private Sub Encbtn_Click(sender As Object, e As EventArgs) Handles Encbtn.Click CTtxt.Text = VigenereCipher.Encrypt(PTtxt.Text, Keytxt.Text) End Sub Private Sub Decbtn_Click(sender As Object, e As EventArgs) Handles Decbtn.Click CTtxt.Text = VigenereCipher.Decrypt(PTtxt.Text, Keytxt.Text) End Sub
  • 6. Computer Security & Networks Dr. Saif Kassim Alfraije Page 6 Public Class VigenereCipher Public Shared Function Encrypt(ByVal plainTxt As String, ByVal key As String) Dim encryptedText As String = "" For i As Integer = 1 To cipherTxt.Length Dim temp As Integer = AscW(GetChar(cipherTxt, i)) + AscW(GetChar(key, i Mod key.Length + 1)) encryptedText += ChrW(temp) Next Return encryptedText End Function Public Shared Function Decrypt(ByVal cipherTxt As String, ByVal key As String) Dim decryptedText As String = "" For i As Integer = 1 To cipherTxt.Length Dim temp As Integer = AscW(GetChar(cipherTxt, i)) - AscW(GetChar(key, i Mod key.Length + 1)) decryptedText += ChrW(temp) Next Return decryptedText End Function End Class
  • 7. Computer Security & Networks Dr. Saif Kassim Alfraije Page 7 One Time Pad Cipher known as Vernam Cipher is implemented using a random set of non repeating characters as the Key. The rest of process is same as the Vigenère cipher. The sender uses each key letter on the pad to encrypt exactly one plaintext character. Encryption is the addition modulo 26 of the plaintext character and the one-time pad key character (Pencoding + Kencoding) >= 26 then - 26 Example: ( Encryption ) Plaintext: “ HOW ARE YOU ’’ Key = NCBTZQARX Ciphertext: ? Plain text H O W A R E Y O U Pencoding 7 14 22 0 17 4 24 14 20 Key N C B T Z Q A R X Kencoding 13 2 1 19 25 16 0 17 23 Cipher Code 20 16 23 19 16 20 24 5 17 Cipher text U Q X T Q U Y F R +
  • 8. Computer Security & Networks Dr. Saif Kassim Alfraije Page 8 (Decryption) Cipher text U Q X T Q U Y F R Cipher Code 20 16 23 19 16 20 24 5 17 Key N C B T Z Q A R X Kencoding 13 2 1 19 25 16 0 17 23 Pencoding 7 14 22 0 17 4 24 14 20 Plain text H O W A R E Y O U - 16 – 25 = – 9 26 – 9 = 17
  • 9. Computer Security & Networks Dr. Saif Kassim Alfraije Page 9 Playfair Cipher The Playfair cipher encrypts pairs of letters, instead of single letters. This is significantly harder to break. Each plaintext letter is replaced by a diagram in this cipher.  User chooses a keyword and puts it in the cells of a 5 x 5 matrix.  Letter I and J always stay in one cell .  Duplicate letters appear only once.  Number of diagrams is 26 x 26 = 676.  To encrypt a message, one would break the message into groups of 2 letters. If there is a dangling letter at the end, we add an X. For example. "Secret Message" becomes "SE CR ET ME SS AG EX". We now take each group and find them out on the table. we apply the following rules, in order. Playfair Cipher Rules 1. If the digraph consists of the same letter twice (or there is only one letter left by itself at the end of the plaintext) then insert the letter "X" between the same letters (or at the end), and then continue with the rest of the steps. 2. If the two letters appear on the same row in the square, then replace each letter by the letter immediately to the right of it in the square (cycling round to the left hand side if necessary). 3. If the two letters appear in the same column in the square, then replace each letter by the letter immediately below it in the square (cycling round to the top of the square if necessary). 4. Otherwise, form the rectangle for which the two plaintext letters are two opposite corners. Then replace each plaintext letter with the letter that forms the other corner of the rectangle that lies on the same row as that plaintext letter (being careful to maintain the order).
  • 10. Computer Security & Networks Dr. Saif Kassim Alfraije Page 10 Example Plain text = Hide the gold in the tree stump , key = playfair example , Cipher text ?? Firstly we must generate the Polybius Square that we are going to use. We do this by setting out a 5x5 grid, and filling it with the alphabet, starting with the letters of the keyphrase, and ignoring any letters we already have in the square. We are also going to combine "I" and "J" in the square. We must now split the plaintext into digraphs, and split up any double letter digraphs by inserting an "x" between them. The first image below shows the initial digraph split of the plaintext, and the second image displays how we split up the "ee" into "ex" and "es". In this case, when we insert this extra "x", we no longer need to have one at the end of the plaintext. HI DE TH EG OL DI NT HE TR EE ST UM P P L A Y F I R E X M B C D G H K N O Q S T U V W Z HI DE TH EG OL DI NT HE TR EX ES TU MP
  • 11. Computer Security & Networks Dr. Saif Kassim Alfraije Page 11 We now take each digraph in turn and apply rule 2, 3 or 4 as necessary. Each step is show below with a visual representation of what is done for each digraph.
  • 12. Computer Security & Networks Dr. Saif Kassim Alfraije Page 12
  • 13. Computer Security & Networks Dr. Saif Kassim Alfraije Page 13
  • 14. Computer Security & Networks Dr. Saif Kassim Alfraije Page 14
  • 15. Computer Security & Networks Dr. Saif Kassim Alfraije Page 15 We can now take each of the ciphertext digraphs that we produced and put them all together. BM OD ZB XD NA BE KU DM UI XM MO UV IF Homework Decrypt the Cipher text = BMODZBXDNABEKUDMUIXMMOUVIF . When the key = playfair example
  • 16. Computer Security & Networks Dr. Saif Kassim Alfraije Page 16 Hill Cipher The Hill Cipher was invented by Lester S. Hill in 1929, and like the other Digraphic Ciphersit acts on groups of letters. Unlike the others though it is extendable to work on different sized blocks of letters. So, technically it is a polygraphic substitution cipher, as it can work on digraphs, trigraphs (3 letter blocks) or theoretically any sized blocks. The Hill Cipher uses an area of mathematics called Linear Algebra, and in particular requires the user to have an elementary understanding of matrices. It also make use of Modulo Arithmetic (like the Affine Cipher). Because of this, the cipher has a significantly more mathematical nature than some of the others. However, it is this nature that allows it to act (relatively) easily on larger blocks of letters. Encryption To encrypt a message using the Hill Cipher we must first turn our keyword into a key matrix (a 2 x 2 matrix for working with digraphs, a 3 x 3 matrix for working with trigraphs, etc). We also turn the plaintext into digraphs (or trigraphs) and each of these into a column vector. We then perform matrix multiplication modulo the length of the alphabet (i.e. 26) on each vector. These vectors are then converted back into letters to produce the ciphertext. 2 x 2 Example We shall encrypt the plaintext message "short example" using the keyword hill and a 2 x 2 matrix. The first step is to turn the keyword into a matrix. With the keyword in a matrix, we need to convert this into a key matrix.
  • 17. Computer Security & Networks Dr. Saif Kassim Alfraije Page 17 We now split the plaintext into digraphs, and write these as column vectors. That is, in the first column vector we write the first plaintext letter at the top, and the second letter at the bottom Now we must convert the plaintext column vectors in the same way that we converted the keyword into the key matrix. Now we must perform some matrix multiplication. We multiply the key matrix by each column vector in turn. To perform matrix multiplication we "combine" the top row of the key matrix with the column vector to get the top element of the resulting column vector. We then "combine" the bottom row of the key matrix with the column vector to get the bottom element of the resulting column vector.
  • 18. Computer Security & Networks Dr. Saif Kassim Alfraije Page 18 Next we have to take each of these numbers, in our resultant column vector, modulo 26 (remember that means divide by 26 and take the remainder). Finally we have to convert these numbers back to letters, so 0 becomes "A" and 15 becomes "P", and our first two letters of the ciphertext are "AP".
  • 19. Computer Security & Networks Dr. Saif Kassim Alfraije Page 19 Encryption process of the first digraph
  • 20. Computer Security & Networks Dr. Saif Kassim Alfraije Page 20
  • 21. Computer Security & Networks Dr. Saif Kassim Alfraije Page 21
  • 22. Computer Security & Networks Dr. Saif Kassim Alfraije Page 22 Decryption To decrypt a ciphertext encoded using the Hill Cipher, we must find the inverse matrix. Once we have the inverse matrix, the process is the same as encrypting. In general, to find the inverse of the key matrix, we perform the calculation below, where Kis the key matrix, d is the determinant of the key matrix and adj(K) is the adjugate matrix of K. 2 x 2 Example We shall decrypt the example above, so we are using the keyword hill and our ciphertext is "APADJ TFTWLFJ". Step 1 - Find the Multiplicative Inverse of the Determinant The determinant is a number that relates directly to the entries of the matrix. It is found by multiplying the top left number by the bottom right number and subtracting from this the product of the top right number and the bottom left number.
  • 23. Computer Security & Networks Dr. Saif Kassim Alfraije Page 23 We now have to find the multiplicative inverse of the determinant working modulo 26. That is, the number between 1 and 25 that gives an answer of 1 when we multiply it by the determinant. So, in this case, we are looking for the number that we need to multiply 15 by to get an answer of 1 modulo 26. So the multiplicative inverse of the determinant modulo 26 is 7. We shall need this number later. Step 2 - Find the Adjugate Matrix The adjugate matrix is a matrix of the same size as the original. For a 2 x 2 matrix, this is fairly straightforward as it is just moving the elements to different positions and changing a couple of signs.
  • 24. Computer Security & Networks Dr. Saif Kassim Alfraije Page 24 Again, once we have these values we will need to take each of them modulo 26 (in particular, we need to add 26 to the negative values to get a number between 0 and 25. For our example we get the matrix below. Step 3 - Multiply the Multiplicative Inverse of the Determinant by the Adjugate Matrix To get the inverse key matrix, we now multiply the inverse determinant (that was 7 in our case) from step 1 by each of the elements of the adjugate matrix from step 2. Then we take each of these answers modulo 26. Now we have the inverse key matrix, we have to convert the ciphertext into column vectors and multiply the inverse matrix by each column vector in turn, take the results modulo 26 and convert these back into letters to get the plaintext.