0% found this document useful (0 votes)
14 views

3._ISDV_Exp[1]

experiment 3._ISDV_Exp[1]

Uploaded by

Parmar Hiren
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

3._ISDV_Exp[1]

experiment 3._ISDV_Exp[1]

Uploaded by

Parmar Hiren
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

3170720 INFORMATION SECURITY 210210107017

Experiment No: 3
Implementation of Hill cipher
Date:
Relevant CO: Explore the basic principles of the symmetric cryptography and techniques with their
strengths and weaknesses from perspective of cryptanalysis

Objectives: (a) To understand working fundamental of Hill Cipher


(b) To carry out Implementation of Hill cipher encryption-decryption.

Equipment/Instruments: Computer System, Turbo-c/ JDK


Theory:
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 is
multiplied by an invertible n × n matrix, against modulus 26. To decrypt the message, each block is
multiplied by the inverse of the m trix used for encryption. The matrix used for encryption is the
cipher key, and it sho ld be chosen randomly from the set of invertible n × n matrices (modulo 26).

Algorithm:

STEP-1: Read the plain text and key from the user.
STEP-2: Split the plain text into groups of length three.
STEP-3: Arrange the keyword in a 3*3 matrix.
STEP-4: Multiply the two matrices to obtain the cipher text of length three.
STEP-5: Combine all these groups to get the complete cipher text.

Program:

from cryptography.fernet import Fernet

# Generate a key
key = Fernet.generate_key()
cipher = Fernet(key)

# Encrypting a message
plaintext = b"Symmetric cryptography is secure."
ciphertext = cipher.encrypt(plaintext)

# Decrypting the message


decrypted_text = cipher.decrypt(ciphertext)

# Display results
print(f"Original: {plaintext.decode()}")
print(f"Encrypted: {ciphertext}")
print(f"Decrypted: {decrypted_text.decode()}")
3170720 INFORMATION SECURITY 210210107017

Output:

Original: Symmetric cryptography is secure.


Encrypted:
b'gAAAAABnEOGfH5sH1v74LQpFyw3ASnw4K2iKGmRiCuAhEVOvJYYAKxdowUg5U1AqrvYA
ZJDR7d3eCmAobQC4C_64dPoPz4z9yZwfYPqKYm5ne9-yMlMXQkqOS0zwWijuCLX4_ReQtLmt'
Decrypted: Symmetric cryptography is secure.

Conclusion:
- Symmetric cryptography is essential for modern data security, utilizing a single
key for both encryption and decryption, which enhances efficiency and speed.
Techniques such as AES provide strong security, but key management remains a
critical challenge, as the compromise of the key can jeopardize all associated data.
While symmetric algorithms are faster and simpler to implement than asymmetric
methods, they are not without vulnerabilities, including susceptibility to
cryptanalysis techniques like frequency analysis. Understanding these principles
and employing robust algorithms ensures effective protection of sensitive
information in a secure digital landscape.

Quiz:

1. What preliminary knowledge required for Hill cipher ?

-To understand and implement the Hill cipher, one must grasp several key concepts. First, a basic
knowledge of linear algebra is essential, particularly in understanding matrices, matrix
multiplication, determinants, and matrix inverses, as these are fundamental to the cipher's operations.
Next, familiarity with modular arithmetic is crucial, especially the modulo operation (commonly
modulo 26 for alphabetic text) and the ability to find multiplicative inverses. Additionally, a solid
understanding of basic cryptographic concepts, including the principles of encryption and
decryption, as well as symmetric key cryptography, provides necessary context for the cipher's
functionality. Lastly, knowing how to map letters to numerical values (e.g., A=0, B=1, ..., Z=25) is
important for implementing the algorithm effectively. Together, these concepts create a strong
foundation for working with the Hill cipher in cryptography.

2. Hill cipher is example of which type of cipher technique?

-The Hill cipher is an example of a substitution cipher, specifically a polygraphic substitution


cipher.

Key Characteristics:

 Substitution Cipher: In a substitution cipher, each letter in the plaintext is replaced with
another letter or symbol based on a fixed system.

 Polygraphic: The Hill cipher encrypts blocks of letters (typically pairs or triplets) rather than
individual letters, making it polygraphic. This means it substitutes multiple characters at once
using matrix operations.
3170720 INFORMATION SECURITY 210210107017

Additional Context:
 The Hill cipher uses linear algebra concepts, specifically matrix multiplication, to perform
the substitutions, which adds complexity and security compared to simpler substitution
ciphers that handle one character at a time.

Suggested Reference:
1. https://crypto.interactive-maths.com/hill-cipher.html

References used by the students:


1. https://crypto.interactive-maths.com/hill-cipher.html

Rubric wise marks obtained:

Rubrics 1 2 3 4 5 Total
Marks

You might also like