SlideShare ist ein Scribd-Unternehmen logo
1 von 15
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

Weitere ähnliche Inhalte

Was ist angesagt?

Elliptic Curve Cryptography
Elliptic Curve CryptographyElliptic Curve Cryptography
Elliptic Curve CryptographyAdri Jovin
 
Machine Learning for Threat Detection
Machine Learning for Threat DetectionMachine Learning for Threat Detection
Machine Learning for Threat DetectionNapier University
 
VTU Design and Analysis of Algorithms(DAA) Lab Manual by Nithin, VVCE, Mysuru...
VTU Design and Analysis of Algorithms(DAA) Lab Manual by Nithin, VVCE, Mysuru...VTU Design and Analysis of Algorithms(DAA) Lab Manual by Nithin, VVCE, Mysuru...
VTU Design and Analysis of Algorithms(DAA) Lab Manual by Nithin, VVCE, Mysuru...Nithin Kumar,VVCE, Mysuru
 
Network Security and Cryptography
Network Security and CryptographyNetwork Security and Cryptography
Network Security and CryptographyAdam Reagan
 
Cyber security landscape
Cyber security landscapeCyber security landscape
Cyber security landscapeJisc
 
Information Security & Cryptography
Information Security & CryptographyInformation Security & Cryptography
Information Security & CryptographyArun ACE
 
Homomorphic Encryption Scheme.pptx
Homomorphic Encryption Scheme.pptxHomomorphic Encryption Scheme.pptx
Homomorphic Encryption Scheme.pptxSneha S K
 
Image encryption and decryption
Image encryption and decryptionImage encryption and decryption
Image encryption and decryptionAashish R
 
Network Security & Cryptography
Network Security & CryptographyNetwork Security & Cryptography
Network Security & CryptographyDr. Himanshu Gupta
 
The role of big data, artificial intelligence and machine learning in cyber i...
The role of big data, artificial intelligence and machine learning in cyber i...The role of big data, artificial intelligence and machine learning in cyber i...
The role of big data, artificial intelligence and machine learning in cyber i...Aladdin Dandis
 
Information Security Career Day Presentation
Information Security Career Day PresentationInformation Security Career Day Presentation
Information Security Career Day Presentationdjglass
 
Cryptography and Information Security
Cryptography and Information SecurityCryptography and Information Security
Cryptography and Information SecurityDr Naim R Kidwai
 
Public key cryptography
Public key cryptography Public key cryptography
Public key cryptography rinnocente
 
Research paper on cyber security.
Research paper on cyber security.Research paper on cyber security.
Research paper on cyber security.Hussain777
 
Cryptography-Known plain text attack
Cryptography-Known plain text attack Cryptography-Known plain text attack
Cryptography-Known plain text attack amiteshg
 
Introduction to Cryptography
Introduction to CryptographyIntroduction to Cryptography
Introduction to CryptographyMd. Afif Al Mamun
 

Was ist angesagt? (20)

Elliptic Curve Cryptography
Elliptic Curve CryptographyElliptic Curve Cryptography
Elliptic Curve Cryptography
 
Machine Learning for Threat Detection
Machine Learning for Threat DetectionMachine Learning for Threat Detection
Machine Learning for Threat Detection
 
VTU Design and Analysis of Algorithms(DAA) Lab Manual by Nithin, VVCE, Mysuru...
VTU Design and Analysis of Algorithms(DAA) Lab Manual by Nithin, VVCE, Mysuru...VTU Design and Analysis of Algorithms(DAA) Lab Manual by Nithin, VVCE, Mysuru...
VTU Design and Analysis of Algorithms(DAA) Lab Manual by Nithin, VVCE, Mysuru...
 
Network Security and Cryptography
Network Security and CryptographyNetwork Security and Cryptography
Network Security and Cryptography
 
Cyber security landscape
Cyber security landscapeCyber security landscape
Cyber security landscape
 
Image Encryption in java ppt.
Image Encryption in java ppt.Image Encryption in java ppt.
Image Encryption in java ppt.
 
Information Security & Cryptography
Information Security & CryptographyInformation Security & Cryptography
Information Security & Cryptography
 
Homomorphic Encryption Scheme.pptx
Homomorphic Encryption Scheme.pptxHomomorphic Encryption Scheme.pptx
Homomorphic Encryption Scheme.pptx
 
Image encryption and decryption
Image encryption and decryptionImage encryption and decryption
Image encryption and decryption
 
Network Security & Cryptography
Network Security & CryptographyNetwork Security & Cryptography
Network Security & Cryptography
 
The role of big data, artificial intelligence and machine learning in cyber i...
The role of big data, artificial intelligence and machine learning in cyber i...The role of big data, artificial intelligence and machine learning in cyber i...
The role of big data, artificial intelligence and machine learning in cyber i...
 
Information Security Career Day Presentation
Information Security Career Day PresentationInformation Security Career Day Presentation
Information Security Career Day Presentation
 
Cryptography and Information Security
Cryptography and Information SecurityCryptography and Information Security
Cryptography and Information Security
 
Public key cryptography
Public key cryptography Public key cryptography
Public key cryptography
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
 
Research paper on cyber security.
Research paper on cyber security.Research paper on cyber security.
Research paper on cyber security.
 
Cryptography-Known plain text attack
Cryptography-Known plain text attack Cryptography-Known plain text attack
Cryptography-Known plain text attack
 
Introduction to Cryptography
Introduction to CryptographyIntroduction to Cryptography
Introduction to Cryptography
 
One time Pad Encryption
One time Pad EncryptionOne time Pad Encryption
One time Pad Encryption
 
Cryptography
CryptographyCryptography
Cryptography
 

Ähnlich wie Activity Hill Cipher.pptx

Convolution presentation
Convolution presentationConvolution presentation
Convolution presentationSoham 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 rsaSoham 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.pdfDhanuskarSankar1
 
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
 
Coding theory.pdf
Coding theory.pdfCoding theory.pdf
Coding theory.pdf230231060
 
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 CryptographyCSCJournals
 
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 MachinesComputer 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
 
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 SCRAMBLINGJournal 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
 
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 CODESIJNSA Journal
 
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.pdfYodalee
 

Ähnlich wie 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
 

Mehr von karthikaparthasarath

BASIC COMPUTER ORGANIZATION unit 1.pptx
BASIC COMPUTER ORGANIZATION unit 1.pptxBASIC COMPUTER ORGANIZATION unit 1.pptx
BASIC COMPUTER ORGANIZATION unit 1.pptxkarthikaparthasarath
 
Fundamentals of Computers MCQS.docx
Fundamentals of Computers MCQS.docxFundamentals of Computers MCQS.docx
Fundamentals of Computers MCQS.docxkarthikaparthasarath
 
Software Engineering Question Bank.docx
Software Engineering Question Bank.docxSoftware Engineering Question Bank.docx
Software Engineering Question Bank.docxkarthikaparthasarath
 
BASIC COMPUTER ORGANIZATION unit 1.pptx
BASIC COMPUTER ORGANIZATION unit 1.pptxBASIC COMPUTER ORGANIZATION unit 1.pptx
BASIC COMPUTER ORGANIZATION unit 1.pptxkarthikaparthasarath
 
ATTACKER TECHNIQUES AND MOTIVATION.pptx
ATTACKER TECHNIQUES AND MOTIVATION.pptxATTACKER TECHNIQUES AND MOTIVATION.pptx
ATTACKER TECHNIQUES AND MOTIVATION.pptxkarthikaparthasarath
 
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.pptxkarthikaparthasarath
 
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.pdfkarthikaparthasarath
 
Heuristic Search Techniques Unit -II.ppt
Heuristic Search Techniques Unit -II.pptHeuristic Search Techniques Unit -II.ppt
Heuristic Search Techniques Unit -II.pptkarthikaparthasarath
 
Heuristic Search Techniques Unit -II.ppt
Heuristic Search Techniques Unit -II.pptHeuristic Search Techniques Unit -II.ppt
Heuristic Search Techniques Unit -II.pptkarthikaparthasarath
 
UNIT III Process Synchronization.docx
UNIT III Process Synchronization.docxUNIT III Process Synchronization.docx
UNIT III Process Synchronization.docxkarthikaparthasarath
 
Android Lab Mannual 18SUITSP5.docx
Android Lab Mannual 18SUITSP5.docxAndroid Lab Mannual 18SUITSP5.docx
Android Lab Mannual 18SUITSP5.docxkarthikaparthasarath
 
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.pptxkarthikaparthasarath
 

Mehr von 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
 

Kürzlich hochgeladen

Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Pooja Bhuva
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxmarlenawright1
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxPooja Bhuva
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxJisc
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Pooja Bhuva
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 

Kürzlich hochgeladen (20)

Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 

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.