Appliedlinearpbl

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

JAYPEE INSTITUTE OF INFORMATION TECHNOLOGY

APPLIED LINEAR ALGEBRA

TOPIC:Matrix-Based Encryption and


Decryption System
PROJECT REPORT
Submitted by:
S.No. Enrolment Phone Name Batch
Number
1. 20103071 7318177666 Utkarsh Kathpalia B3
2. 20102032 9310124506 Mrigank Soni A2

Under the Supervision of:


Dr. Ram Surat Chauhan
Department of Mathematics
JIIT, Sector 62, Noida
OBJECTIVE
To develop a simple cryptographic system that utilizes matrix operations for encrypting and decrypting text
messages.

PROJECT DESCRIPTION
This project will involve creating an encryption algorithm using linear algebra concepts, specifically matrix
multiplication. The encryption process will transform plain text into ciphertext using a key matrix, and the
decryption process will reverse this using an inverse matrix.

Theoretical Foundation

Basics of Cryptography:

 Cryptography is the practice and study of techniques for secure communication.

 It involves converting information from its normal, comprehensible form into an incomprehensible
format and vice-versa.

Linear Algebra in Cryptography:

 Linear algebra, especially matrix operations, plays a crucial role in several cryptographic algorithms.

 Matrix multiplication and inverse are key operations used in encrypting and decrypting messages.
Algorithm Design

Text to Matrix Conversion:

 Convert each character of the plaintext into a numerical value (e.g., ASCII values).

 Arrange these values into a matrix format suitable for multiplication with the key matrix.

Key Matrix:

 Choose or generate a square matrix as the key.

 Ensure this key matrix is invertible (this is crucial for decryption).

Encryption Process:

 Multiply the plaintext matrix with the key matrix.

 The resultant matrix is your encrypted data.

Decryption Process:

 Multiply the encrypted matrix by the inverse of the key matrix.

 Convert the resultant matrix back to text.


Implementation
Let's implement a basic version of this in Python:

Preparation:

 Decide on the size of the key matrix (e.g., 2x2, 3x3, etc.).

 Write functions to convert text to a matrix and vice versa.

Key Matrix and Inverse:

 Generate a random invertible matrix as the key.

 Compute its inverse.

Encryption and Decryption Functions:

 Write functions for the encryption and decryption process.

Testing:

 Encrypt a sample text and then decrypt it to verify the process.


CODE
CODE ANALYSIS
Key Matrix Generation:

The generated key matrix is a 2x2 matrix with random integers:

23 10
( )
21 3

Inverse Key Matrix:

The inverse of the key matrix, crucial for decryption, is calculated as:

−0.0212766 0.07092199
( )
0.14893617 −0.16312057

Note that these are floating-point numbers, which we'll need to handle during decryption.

Text Conversion Functions:

 text_to_matrix: Converts text into a numerical matrix based on ASCII values.


 matrix_to_text: Converts numerical matrices back to text.

Next, we'll implement the encryption and decryption functions. These functions will perform the
matrix multiplication for encryption and use the inverse matrix for decryption. We also need to
handle the conversion of the resulting matrices back into text, considering any rounding or
conversion issues due to floating-point operations in the inverse matrix.

Let's proceed with this implementation.

The encryption and decryption functions have been successfully implemented:

Encryption:

The text "hello world" was converted into a numerical matrix and then encrypted using the key matrix. The
encrypted matrix looks like this (note the negative and large values due to matrix multiplication):

Decryption:

The decryption process involved multiplying the encrypted matrix by the inverse of the key matrix and
converting it back to text.
The decrypted text is "hello world", matching the original input (with an additional space due to padding
during the text-to-matrix conversion).
REFERENCES

 McKinney, W. (n.d.). Python for Data Analysis. [Textbook].

 Trefethen, L. N., & Bau III, D. (n.d.). Numerical Linear Algebra. [Textbook].

 "NumPy Documentation". (n.d.). Retrieved from NumPy Official Website.

 "Crypto Stack Exchange". (n.d.). Retrieved from https://crypto.stackexchange.com/.

You might also like