SlideShare a Scribd company logo
HILL CIPHER
BY
AJAY THARAN P
 Hill cipher is a polygraphic substitution cipher based on linear algebra. Each letter
is represented by a number modulo 26.
 Often the simple scheme A = 0, B = 1, …, Z = 25 is used, but this is not an
essential feature of the cipher.
 To encrypt a message, each block of n letters (considered as an n-component
vector) is multiplied by an invertible n × n matrix, against modulus 26.
 To decrypt the message, each block is multiplied by the
inverse of the matrix used for encryption.
 The matrix used for encryption is the cipher key, and it
should be chosen randomly from the set of invertible n ×
n matrices (modulo 26).
Examples:
Input : Plaintext: ACT Key: GYBNQKURP
Output : Ciphertext: POH
Input : Plaintext: GFG Key: HILLMAGIC
Output : Ciphertext: SWK
Encryption
 We have to encrypt the message ‘ACT’ (n=3).The key is ‘GYBNQKURP’ which can be written
as the nxn matrix:
 The message ‘ACT’ is written as vector:
The enciphered vector is given as:
Decryption
 To decrypt the message, we turn the ciphertext back into a vector, then simply
multiply by the inverse matrix of the key matrix (IFKVIVVMI in letters).
 The inverse of the matrix used in the previous example is:
 For the previous Ciphertext ‘POH’:
 which gives us back ‘ACT’.
Assume that all the alphabets are in upper case.
Below is the implementation of the above idea for n=3.
Code :
// Java code to implement Hill Cipher
class GFG
{
// Following function generates the
// key matrix for the key string
static void getKeyMatrix(String key, int keyMatrix[][])
{ int k = 0;
for (int i = 0; i < 3; i++)
{ for (int j = 0; j < 3; j++){
keyMatrix[i][j] = (key.charAt(k)) % 65;
k++;
}}}
// Following function encrypts the message
static void encrypt(int cipherMatrix[][],
int keyMatrix[][],int messageVector[][])
{int x, i, j;
for (i = 0; i < 3; i++)
{for (j = 0; j < 1; j++)
{ cipherMatrix[i][j] = 0;
for (x = 0; x < 3; x++) {
cipherMatrix[i][j] +=
keyMatrix[i][x] * messageVector[x][j];
}
cipherMatrix[i][j] = cipherMatrix[i][j] % 26;
}}}
// Function to implement Hill Cipher
static void HillCipher(String message, String key)
{
// Get key matrix from the key string
int [][]keyMatrix = new int[3][3];
getKeyMatrix(key, keyMatrix);
int [][]messageVector = new int[3][1]; // Generate vector for the message
for (int i = 0; i < 3; i++)
messageVector[i][0] = (message.charAt(i)) % 65;
int [][]cipherMatrix = new int[3][1];
// Following function generates
// the encrypted vector
encrypt(cipherMatrix, keyMatrix, messageVector);
String CipherText="";
// Generate the encrypted text from
// the encrypted vector
for (int i = 0; i < 3; i++)
CipherText += (char)(cipherMatrix[i][0] + 65);
// Finally print the ciphertext
System.out.print(" Ciphertext:" + CipherText);
}
public static void main(String[] args)
{
// Get the message to be encrypted
String message = "ACT";
// Get the key
String key = "GYBNQKURP";
HillCipher(message, key);
}}
Output :
Ciphertext: POH
https://www.dcode.fr/hill-cipher
Thank you

More Related Content

What's hot

The Diffie-Hellman Algorithm
The Diffie-Hellman AlgorithmThe Diffie-Hellman Algorithm
The Diffie-Hellman Algorithm
Jay Nagar
 
Paillier-ElGamal cryptosystem presentation
Paillier-ElGamal cryptosystem presentationPaillier-ElGamal cryptosystem presentation
Paillier-ElGamal cryptosystem presentation
GauthamSK4
 
Elliptic curvecryptography Shane Almeida Saqib Awan Dan Palacio
Elliptic curvecryptography Shane Almeida Saqib Awan Dan PalacioElliptic curvecryptography Shane Almeida Saqib Awan Dan Palacio
Elliptic curvecryptography Shane Almeida Saqib Awan Dan Palacio
Information Security Awareness Group
 
Automata theory - RE to DFA Conversion
Automata theory - RE to DFA ConversionAutomata theory - RE to DFA Conversion
Automata theory - RE to DFA Conversion
Akila Krishnamoorthy
 
Ejemplo metodo kasiski
Ejemplo metodo kasiskiEjemplo metodo kasiski
Ejemplo metodo kasiskiG Hoyos A
 
Monoalphabetic Substitution Cipher
Monoalphabetic Substitution  CipherMonoalphabetic Substitution  Cipher
Monoalphabetic Substitution Cipher
SHUBHA CHATURVEDI
 
Elliptic Curve Cryptography
Elliptic Curve CryptographyElliptic Curve Cryptography
Elliptic Curve Cryptography
JorgeVillamarin5
 
Rc4
Rc4Rc4
computer-security-and-cryptography-a-simple-presentation
computer-security-and-cryptography-a-simple-presentationcomputer-security-and-cryptography-a-simple-presentation
computer-security-and-cryptography-a-simple-presentation
Alex Punnen
 
ElGamal Encryption in Go
ElGamal Encryption in GoElGamal Encryption in Go
ElGamal Encryption in Go
Napier University
 
SHA-3
SHA-3SHA-3
A Tutorial on Linear and Differential Cryptanalysis by Howard M. Heys
A Tutorial on Linear and Differential Cryptanalysis by Howard M. HeysA Tutorial on Linear and Differential Cryptanalysis by Howard M. Heys
A Tutorial on Linear and Differential Cryptanalysis by Howard M. Heys
Information Security Awareness Group
 
Cifrado por sustitución
Cifrado por sustituciónCifrado por sustitución
Cifrado por sustituciónG Hoyos A
 
Lab report
Lab reportLab report
Lab report
Md Selim Hossain
 
Classical encryption techniques
Classical encryption techniquesClassical encryption techniques
Classical encryption techniques
Janani S
 
2-bit comparator
2-bit comparator2-bit comparator
2-bit comparator
إسلام عادل
 
Applications of linear algebra in computer science
Applications of linear algebra in computer scienceApplications of linear algebra in computer science
Applications of linear algebra in computer science
Arnob Khan
 
Insertion sort
Insertion sortInsertion sort
Insertion sort
Rajendran
 

What's hot (20)

The Diffie-Hellman Algorithm
The Diffie-Hellman AlgorithmThe Diffie-Hellman Algorithm
The Diffie-Hellman Algorithm
 
Paillier-ElGamal cryptosystem presentation
Paillier-ElGamal cryptosystem presentationPaillier-ElGamal cryptosystem presentation
Paillier-ElGamal cryptosystem presentation
 
Elliptic curvecryptography Shane Almeida Saqib Awan Dan Palacio
Elliptic curvecryptography Shane Almeida Saqib Awan Dan PalacioElliptic curvecryptography Shane Almeida Saqib Awan Dan Palacio
Elliptic curvecryptography Shane Almeida Saqib Awan Dan Palacio
 
Crypto graphy
Crypto graphyCrypto graphy
Crypto graphy
 
Automata theory - RE to DFA Conversion
Automata theory - RE to DFA ConversionAutomata theory - RE to DFA Conversion
Automata theory - RE to DFA Conversion
 
Ejemplo metodo kasiski
Ejemplo metodo kasiskiEjemplo metodo kasiski
Ejemplo metodo kasiski
 
Monoalphabetic Substitution Cipher
Monoalphabetic Substitution  CipherMonoalphabetic Substitution  Cipher
Monoalphabetic Substitution Cipher
 
Elliptic Curve Cryptography
Elliptic Curve CryptographyElliptic Curve Cryptography
Elliptic Curve Cryptography
 
Rc4
Rc4Rc4
Rc4
 
computer-security-and-cryptography-a-simple-presentation
computer-security-and-cryptography-a-simple-presentationcomputer-security-and-cryptography-a-simple-presentation
computer-security-and-cryptography-a-simple-presentation
 
ElGamal Encryption in Go
ElGamal Encryption in GoElGamal Encryption in Go
ElGamal Encryption in Go
 
SHA-3
SHA-3SHA-3
SHA-3
 
A Tutorial on Linear and Differential Cryptanalysis by Howard M. Heys
A Tutorial on Linear and Differential Cryptanalysis by Howard M. HeysA Tutorial on Linear and Differential Cryptanalysis by Howard M. Heys
A Tutorial on Linear and Differential Cryptanalysis by Howard M. Heys
 
Cifrado por sustitución
Cifrado por sustituciónCifrado por sustitución
Cifrado por sustitución
 
Lab report
Lab reportLab report
Lab report
 
Classical encryption techniques
Classical encryption techniquesClassical encryption techniques
Classical encryption techniques
 
2-bit comparator
2-bit comparator2-bit comparator
2-bit comparator
 
Ecc2
Ecc2Ecc2
Ecc2
 
Applications of linear algebra in computer science
Applications of linear algebra in computer scienceApplications of linear algebra in computer science
Applications of linear algebra in computer science
 
Insertion sort
Insertion sortInsertion sort
Insertion sort
 

Similar to Activity Hill Cipher.pptx

Convolution presentation
Convolution presentationConvolution presentation
Convolution presentation
Soham Mondal
 
Novel encryption algorithm and software development ecc and rsa
Novel encryption algorithm and software development ecc and rsaNovel encryption algorithm and software development ecc and rsa
Novel encryption algorithm and software development ecc and rsa
Soham Mondal
 
IT8761-SECURITY LABORATORY-590519304-IT8761 security labmanual.pdf
IT8761-SECURITY LABORATORY-590519304-IT8761 security labmanual.pdfIT8761-SECURITY LABORATORY-590519304-IT8761 security labmanual.pdf
IT8761-SECURITY LABORATORY-590519304-IT8761 security labmanual.pdf
DhanuskarSankar1
 
Asssignment2
Asssignment2 Asssignment2
Asssignment2
AnnamalikAnnamalik
 
Presentation on Cryptography_Based on IEEE_Paper
Presentation on Cryptography_Based on IEEE_PaperPresentation on Cryptography_Based on IEEE_Paper
Presentation on Cryptography_Based on IEEE_PaperNithin Cv
 
F010243136
F010243136F010243136
F010243136
IOSR Journals
 
Coding theory.pdf
Coding theory.pdfCoding theory.pdf
Coding theory.pdf
230231060
 
On the Usage of Chained Codes in Cryptography
On the Usage of Chained Codes in CryptographyOn the Usage of Chained Codes in Cryptography
On the Usage of Chained Codes in Cryptography
CSCJournals
 
An ElGamal Encryption Scheme of Adjacency Matrix and Finite Machines
An ElGamal Encryption Scheme of Adjacency Matrix and Finite MachinesAn ElGamal Encryption Scheme of Adjacency Matrix and Finite Machines
An ElGamal Encryption Scheme of Adjacency Matrix and Finite Machines
Computer Science Journals
 
Ijarcet vol-2-issue-7-2323-2327
Ijarcet vol-2-issue-7-2323-2327Ijarcet vol-2-issue-7-2323-2327
Ijarcet vol-2-issue-7-2323-2327Editor IJARCET
 
Ijarcet vol-2-issue-7-2323-2327
Ijarcet vol-2-issue-7-2323-2327Ijarcet vol-2-issue-7-2323-2327
Ijarcet vol-2-issue-7-2323-2327Editor IJARCET
 
Network Security
Network SecurityNetwork Security
Network Security
Fahad Shaikh
 
CRYPTOGRAPHY USING ELLIPTIC CURVE WITH MATRIX SCRAMBLING
CRYPTOGRAPHY USING ELLIPTIC CURVE WITH MATRIX SCRAMBLINGCRYPTOGRAPHY USING ELLIPTIC CURVE WITH MATRIX SCRAMBLING
CRYPTOGRAPHY USING ELLIPTIC CURVE WITH MATRIX SCRAMBLING
Journal For Research
 
0853352_Report_Valuing Warrants With VBA
0853352_Report_Valuing Warrants With VBA0853352_Report_Valuing Warrants With VBA
0853352_Report_Valuing Warrants With VBAKartik Malla
 
LDPC Encoding
LDPC EncodingLDPC Encoding
LDPC Encoding
Bhagwat Singh Rathore
 
Xgboost
XgboostXgboost
WEAKNESS ON CRYPTOGRAPHIC SCHEMES BASED ON REGULAR LDPC CODES
WEAKNESS ON CRYPTOGRAPHIC SCHEMES BASED ON REGULAR LDPC CODESWEAKNESS ON CRYPTOGRAPHIC SCHEMES BASED ON REGULAR LDPC CODES
WEAKNESS ON CRYPTOGRAPHIC SCHEMES BASED ON REGULAR LDPC CODES
IJNSA Journal
 
Chapter 15 - Security
Chapter 15 - SecurityChapter 15 - Security
Chapter 15 - Security
Wayne Jones Jnr
 
Novel Methods of Generating Self-Invertible Matrix for Hill Cipher Algorithm.
Novel Methods of Generating Self-Invertible Matrix for Hill Cipher Algorithm.Novel Methods of Generating Self-Invertible Matrix for Hill Cipher Algorithm.
Novel Methods of Generating Self-Invertible Matrix for Hill Cipher Algorithm.
CSCJournals
 
COSCUP2023 RSA256 Verilator.pdf
COSCUP2023 RSA256 Verilator.pdfCOSCUP2023 RSA256 Verilator.pdf
COSCUP2023 RSA256 Verilator.pdf
Yodalee
 

Similar to Activity Hill Cipher.pptx (20)

Convolution presentation
Convolution presentationConvolution presentation
Convolution presentation
 
Novel encryption algorithm and software development ecc and rsa
Novel encryption algorithm and software development ecc and rsaNovel encryption algorithm and software development ecc and rsa
Novel encryption algorithm and software development ecc and rsa
 
IT8761-SECURITY LABORATORY-590519304-IT8761 security labmanual.pdf
IT8761-SECURITY LABORATORY-590519304-IT8761 security labmanual.pdfIT8761-SECURITY LABORATORY-590519304-IT8761 security labmanual.pdf
IT8761-SECURITY LABORATORY-590519304-IT8761 security labmanual.pdf
 
Asssignment2
Asssignment2 Asssignment2
Asssignment2
 
Presentation on Cryptography_Based on IEEE_Paper
Presentation on Cryptography_Based on IEEE_PaperPresentation on Cryptography_Based on IEEE_Paper
Presentation on Cryptography_Based on IEEE_Paper
 
F010243136
F010243136F010243136
F010243136
 
Coding theory.pdf
Coding theory.pdfCoding theory.pdf
Coding theory.pdf
 
On the Usage of Chained Codes in Cryptography
On the Usage of Chained Codes in CryptographyOn the Usage of Chained Codes in Cryptography
On the Usage of Chained Codes in Cryptography
 
An ElGamal Encryption Scheme of Adjacency Matrix and Finite Machines
An ElGamal Encryption Scheme of Adjacency Matrix and Finite MachinesAn ElGamal Encryption Scheme of Adjacency Matrix and Finite Machines
An ElGamal Encryption Scheme of Adjacency Matrix and Finite Machines
 
Ijarcet vol-2-issue-7-2323-2327
Ijarcet vol-2-issue-7-2323-2327Ijarcet vol-2-issue-7-2323-2327
Ijarcet vol-2-issue-7-2323-2327
 
Ijarcet vol-2-issue-7-2323-2327
Ijarcet vol-2-issue-7-2323-2327Ijarcet vol-2-issue-7-2323-2327
Ijarcet vol-2-issue-7-2323-2327
 
Network Security
Network SecurityNetwork Security
Network Security
 
CRYPTOGRAPHY USING ELLIPTIC CURVE WITH MATRIX SCRAMBLING
CRYPTOGRAPHY USING ELLIPTIC CURVE WITH MATRIX SCRAMBLINGCRYPTOGRAPHY USING ELLIPTIC CURVE WITH MATRIX SCRAMBLING
CRYPTOGRAPHY USING ELLIPTIC CURVE WITH MATRIX SCRAMBLING
 
0853352_Report_Valuing Warrants With VBA
0853352_Report_Valuing Warrants With VBA0853352_Report_Valuing Warrants With VBA
0853352_Report_Valuing Warrants With VBA
 
LDPC Encoding
LDPC EncodingLDPC Encoding
LDPC Encoding
 
Xgboost
XgboostXgboost
Xgboost
 
WEAKNESS ON CRYPTOGRAPHIC SCHEMES BASED ON REGULAR LDPC CODES
WEAKNESS ON CRYPTOGRAPHIC SCHEMES BASED ON REGULAR LDPC CODESWEAKNESS ON CRYPTOGRAPHIC SCHEMES BASED ON REGULAR LDPC CODES
WEAKNESS ON CRYPTOGRAPHIC SCHEMES BASED ON REGULAR LDPC CODES
 
Chapter 15 - Security
Chapter 15 - SecurityChapter 15 - Security
Chapter 15 - Security
 
Novel Methods of Generating Self-Invertible Matrix for Hill Cipher Algorithm.
Novel Methods of Generating Self-Invertible Matrix for Hill Cipher Algorithm.Novel Methods of Generating Self-Invertible Matrix for Hill Cipher Algorithm.
Novel Methods of Generating Self-Invertible Matrix for Hill Cipher Algorithm.
 
COSCUP2023 RSA256 Verilator.pdf
COSCUP2023 RSA256 Verilator.pdfCOSCUP2023 RSA256 Verilator.pdf
COSCUP2023 RSA256 Verilator.pdf
 

More from karthikaparthasarath

BASIC COMPUTER ORGANIZATION unit 1.pptx
BASIC COMPUTER ORGANIZATION unit 1.pptxBASIC COMPUTER ORGANIZATION unit 1.pptx
BASIC COMPUTER ORGANIZATION unit 1.pptx
karthikaparthasarath
 
Fundamentals of Computers MCQS.docx
Fundamentals of Computers MCQS.docxFundamentals of Computers MCQS.docx
Fundamentals of Computers MCQS.docx
karthikaparthasarath
 
Software Engineering Question Bank.docx
Software Engineering Question Bank.docxSoftware Engineering Question Bank.docx
Software Engineering Question Bank.docx
karthikaparthasarath
 
BASIC COMPUTER ORGANIZATION unit 1.pptx
BASIC COMPUTER ORGANIZATION unit 1.pptxBASIC COMPUTER ORGANIZATION unit 1.pptx
BASIC COMPUTER ORGANIZATION unit 1.pptx
karthikaparthasarath
 
ATTACKER TECHNIQUES AND MOTIVATION.pptx
ATTACKER TECHNIQUES AND MOTIVATION.pptxATTACKER TECHNIQUES AND MOTIVATION.pptx
ATTACKER TECHNIQUES AND MOTIVATION.pptx
karthikaparthasarath
 
Unit - I cyber security fundamentals part -1.pptx
Unit - I cyber security fundamentals part -1.pptxUnit - I cyber security fundamentals part -1.pptx
Unit - I cyber security fundamentals part -1.pptx
karthikaparthasarath
 
BUilt in Functions and Simple programs in R.pdf
BUilt in Functions and Simple programs in R.pdfBUilt in Functions and Simple programs in R.pdf
BUilt in Functions and Simple programs in R.pdf
karthikaparthasarath
 
Heuristic Search Techniques Unit -II.ppt
Heuristic Search Techniques Unit -II.pptHeuristic Search Techniques Unit -II.ppt
Heuristic Search Techniques Unit -II.ppt
karthikaparthasarath
 
simple programs.docx
simple programs.docxsimple programs.docx
simple programs.docx
karthikaparthasarath
 
Heuristic Search Techniques Unit -II.ppt
Heuristic Search Techniques Unit -II.pptHeuristic Search Techniques Unit -II.ppt
Heuristic Search Techniques Unit -II.ppt
karthikaparthasarath
 
UNIT III Process Synchronization.docx
UNIT III Process Synchronization.docxUNIT III Process Synchronization.docx
UNIT III Process Synchronization.docx
karthikaparthasarath
 
Android Lab Mannual 18SUITSP5.docx
Android Lab Mannual 18SUITSP5.docxAndroid Lab Mannual 18SUITSP5.docx
Android Lab Mannual 18SUITSP5.docx
karthikaparthasarath
 
Activity playfair cipher.pptx
Activity playfair cipher.pptxActivity playfair cipher.pptx
Activity playfair cipher.pptx
karthikaparthasarath
 
Activity Caesar Cipher.pptx
Activity Caesar Cipher.pptxActivity Caesar Cipher.pptx
Activity Caesar Cipher.pptx
karthikaparthasarath
 
Cyber Security Unit I Part -I.pptx
Cyber Security Unit I Part -I.pptxCyber Security Unit I Part -I.pptx
Cyber Security Unit I Part -I.pptx
karthikaparthasarath
 
Unit I Q&A.docx
Unit I Q&A.docxUnit I Q&A.docx
Unit I Q&A.docx
karthikaparthasarath
 
Unit 1 QB.docx
Unit 1 QB.docxUnit 1 QB.docx
Unit 1 QB.docx
karthikaparthasarath
 
cyber security.pptx
cyber security.pptxcyber security.pptx
cyber security.pptx
karthikaparthasarath
 
UNIT I - Part 1.pptx
UNIT I - Part 1.pptxUNIT I - Part 1.pptx
UNIT I - Part 1.pptx
karthikaparthasarath
 
UNIT II - CPU SCHEDULING.docx
UNIT II - CPU SCHEDULING.docxUNIT II - CPU SCHEDULING.docx
UNIT II - CPU SCHEDULING.docx
karthikaparthasarath
 

More from karthikaparthasarath (20)

BASIC COMPUTER ORGANIZATION unit 1.pptx
BASIC COMPUTER ORGANIZATION unit 1.pptxBASIC COMPUTER ORGANIZATION unit 1.pptx
BASIC COMPUTER ORGANIZATION unit 1.pptx
 
Fundamentals of Computers MCQS.docx
Fundamentals of Computers MCQS.docxFundamentals of Computers MCQS.docx
Fundamentals of Computers MCQS.docx
 
Software Engineering Question Bank.docx
Software Engineering Question Bank.docxSoftware Engineering Question Bank.docx
Software Engineering Question Bank.docx
 
BASIC COMPUTER ORGANIZATION unit 1.pptx
BASIC COMPUTER ORGANIZATION unit 1.pptxBASIC COMPUTER ORGANIZATION unit 1.pptx
BASIC COMPUTER ORGANIZATION unit 1.pptx
 
ATTACKER TECHNIQUES AND MOTIVATION.pptx
ATTACKER TECHNIQUES AND MOTIVATION.pptxATTACKER TECHNIQUES AND MOTIVATION.pptx
ATTACKER TECHNIQUES AND MOTIVATION.pptx
 
Unit - I cyber security fundamentals part -1.pptx
Unit - I cyber security fundamentals part -1.pptxUnit - I cyber security fundamentals part -1.pptx
Unit - I cyber security fundamentals part -1.pptx
 
BUilt in Functions and Simple programs in R.pdf
BUilt in Functions and Simple programs in R.pdfBUilt in Functions and Simple programs in R.pdf
BUilt in Functions and Simple programs in R.pdf
 
Heuristic Search Techniques Unit -II.ppt
Heuristic Search Techniques Unit -II.pptHeuristic Search Techniques Unit -II.ppt
Heuristic Search Techniques Unit -II.ppt
 
simple programs.docx
simple programs.docxsimple programs.docx
simple programs.docx
 
Heuristic Search Techniques Unit -II.ppt
Heuristic Search Techniques Unit -II.pptHeuristic Search Techniques Unit -II.ppt
Heuristic Search Techniques Unit -II.ppt
 
UNIT III Process Synchronization.docx
UNIT III Process Synchronization.docxUNIT III Process Synchronization.docx
UNIT III Process Synchronization.docx
 
Android Lab Mannual 18SUITSP5.docx
Android Lab Mannual 18SUITSP5.docxAndroid Lab Mannual 18SUITSP5.docx
Android Lab Mannual 18SUITSP5.docx
 
Activity playfair cipher.pptx
Activity playfair cipher.pptxActivity playfair cipher.pptx
Activity playfair cipher.pptx
 
Activity Caesar Cipher.pptx
Activity Caesar Cipher.pptxActivity Caesar Cipher.pptx
Activity Caesar Cipher.pptx
 
Cyber Security Unit I Part -I.pptx
Cyber Security Unit I Part -I.pptxCyber Security Unit I Part -I.pptx
Cyber Security Unit I Part -I.pptx
 
Unit I Q&A.docx
Unit I Q&A.docxUnit I Q&A.docx
Unit I Q&A.docx
 
Unit 1 QB.docx
Unit 1 QB.docxUnit 1 QB.docx
Unit 1 QB.docx
 
cyber security.pptx
cyber security.pptxcyber security.pptx
cyber security.pptx
 
UNIT I - Part 1.pptx
UNIT I - Part 1.pptxUNIT I - Part 1.pptx
UNIT I - Part 1.pptx
 
UNIT II - CPU SCHEDULING.docx
UNIT II - CPU SCHEDULING.docxUNIT II - CPU SCHEDULING.docx
UNIT II - CPU SCHEDULING.docx
 

Recently uploaded

Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Po-Chuan Chen
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
CarlosHernanMontoyab2
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 

Recently uploaded (20)

Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 

Activity Hill Cipher.pptx

  • 2.  Hill cipher is a polygraphic substitution cipher based on linear algebra. Each letter is represented by a number modulo 26.  Often the simple scheme A = 0, B = 1, …, Z = 25 is used, but this is not an essential feature of the cipher.  To encrypt a message, each block of n letters (considered as an n-component vector) is multiplied by an invertible n × n matrix, against modulus 26.
  • 3.  To decrypt the message, each block is multiplied by the inverse of the matrix used for encryption.  The matrix used for encryption is the cipher key, and it should be chosen randomly from the set of invertible n × n matrices (modulo 26). Examples: Input : Plaintext: ACT Key: GYBNQKURP Output : Ciphertext: POH Input : Plaintext: GFG Key: HILLMAGIC Output : Ciphertext: SWK
  • 4. Encryption  We have to encrypt the message ‘ACT’ (n=3).The key is ‘GYBNQKURP’ which can be written as the nxn matrix:  The message ‘ACT’ is written as vector:
  • 5. The enciphered vector is given as: Decryption  To decrypt the message, we turn the ciphertext back into a vector, then simply multiply by the inverse matrix of the key matrix (IFKVIVVMI in letters).
  • 6.  The inverse of the matrix used in the previous example is:  For the previous Ciphertext ‘POH’:
  • 7.  which gives us back ‘ACT’. Assume that all the alphabets are in upper case. Below is the implementation of the above idea for n=3.
  • 8. Code : // Java code to implement Hill Cipher class GFG { // Following function generates the // key matrix for the key string static void getKeyMatrix(String key, int keyMatrix[][]) { int k = 0; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++){ keyMatrix[i][j] = (key.charAt(k)) % 65; k++; }}}
  • 9. // Following function encrypts the message static void encrypt(int cipherMatrix[][], int keyMatrix[][],int messageVector[][]) {int x, i, j; for (i = 0; i < 3; i++) {for (j = 0; j < 1; j++) { cipherMatrix[i][j] = 0; for (x = 0; x < 3; x++) { cipherMatrix[i][j] += keyMatrix[i][x] * messageVector[x][j]; }
  • 10. cipherMatrix[i][j] = cipherMatrix[i][j] % 26; }}} // Function to implement Hill Cipher static void HillCipher(String message, String key) { // Get key matrix from the key string int [][]keyMatrix = new int[3][3]; getKeyMatrix(key, keyMatrix); int [][]messageVector = new int[3][1]; // Generate vector for the message for (int i = 0; i < 3; i++) messageVector[i][0] = (message.charAt(i)) % 65; int [][]cipherMatrix = new int[3][1];
  • 11. // Following function generates // the encrypted vector encrypt(cipherMatrix, keyMatrix, messageVector); String CipherText=""; // Generate the encrypted text from // the encrypted vector for (int i = 0; i < 3; i++) CipherText += (char)(cipherMatrix[i][0] + 65); // Finally print the ciphertext System.out.print(" Ciphertext:" + CipherText); }
  • 12. public static void main(String[] args) { // Get the message to be encrypted String message = "ACT"; // Get the key String key = "GYBNQKURP"; HillCipher(message, key); }} Output : Ciphertext: POH
  • 14.