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

Cryptography Using Matrices-3

Uploaded by

Jalaj Pruthi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views

Cryptography Using Matrices-3

Uploaded by

Jalaj Pruthi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

Cryptography

Using Matrices

By Jalaj Pruthi and Jayant Miglani


Introduction
Mathematics is a very useful tool which
is often used in the world of cryptography.
Using our existing knowledge and combining
a few new ideas, we have come up with
several programs which help us encrypt and
decrypt our messages with the help of
some basics concepts that we have learned
in our classes.
Hill Cipher
Hill cipher is a linear algebra-based polygraphic
substitution cipher. A number modulo 26 is assigned
to each letter. The basic scheme A = 0, B = 1,..., Z =
25 is frequently employed, but it is not a requirement
of the encryption. Each block of n letters (considered
an n-component vector) is multiplied by an invertible
n x n matrix against modulus 26 to encrypt a
message.Each block is multiplied by the inverse of
the encryption matrix in order to decrypt the
message.
The cipher key is the matrix used for encryption, and
it should be chosen at random from a set of invertible
n n matrices (modulo 26).
Example of
Hill Cipher
Encrypting with the Hill cipher is built on the
following operation:
E(K, P) = (K*P) mod 26 2. .Next, we will convert our plaintext message
Where K is our key matrix and P is the to vector form. Since our key matrix is 2x2, the
plaintext in vector form. Matrix multiplying vector needs to be 2x1 for matrix multiplication
these two terms produces the encrypted to be possible. In our case, our message is four
ciphertext. Let's do it step by step: letters long so we can split it into blocks of two
and then substitute to get our plaintext vectors.
1. Pick a keyword to encrypt your plaintext
message. Let’s work with the random
keyword “DCDF”. Convert this keyword
to matrix form using your substitution
scheme to convert it to a numerical 2x2
key matrix.
1. First, we calculate the inverse of the key
3. Now, we can matrix multiply the key
matrix. In doing so, we must keep the
matrix with each 2x1 plaintext vector, take
result between 0-25 using modulo 26.
the moduli of the resulting 2x1 vectors by
For this reason, the Extended Euclidean
26, and concatenate the results to get
algorithm is used to find the modular
“WWVA”, the final ciphertext.
multiplicative inverse of the key matrix
determinant.

2. Next, we will multiply 2x1 blocks of the


Decrypting with the Hill cipher is built on the ciphertext with the inverse of the key matrix to
following operation: get our original plaintext message, “CODE,”
D(K, C) = (K-1 *C) mod 26Where K is our key back.
matrix and C is the ciphertext in vector form.
Matrix multiplying the inverse of the key
matrix with the ciphertext produces the
decrypted plaintext. Let's do this step by
step with our ciphertext, "WWVA":
Hill Cipher: How to Proceed
First, it is specified how many plain text letters are to be converted to a cipher text
letter = m.
In our program m = 3.
According to this m, we divide the key to m x m matrix
Convert plain text to an m component vector.

Here, Plain Text message: "MIT" (3)


String Key ="MATHSPROJ" (9)
Encrypted Text is - "LTT"
Code For Hill
Cipher
Columnar Transposition
Cipher
The Columnar Transposition Cipher, like the
Rail Fence Cipher, is a type of transposition
cipher. Columnar Transposition entails
writing plaintext in rows and then reading the
ciphertext one by one in columns.
Example of Columnar Transposition Cipher
In a transposition cipher, the order of the alphabets is re-arranged to obtain the
cipher-text.

1. The message is written out in rows of a fixed length, and then read out again
column by column, and the columns are chosen in some scrambled order.
2.Width of the rows and the permutation of the columns are usually defined by a
keyword.
3.For example, the word HACK is of length 4 (so the rows are of length 4), and the
permutation is defined by the alphabetical order of the letters in the keyword. In
this case, the order would be “3 1 2 4”.
4.Any spare spaces are filled with nulls or left blank or placed by a character
(Example: _).
5.Finally, the message is read off in columns, in the order specified by the
keyword.
ENCRYPTION:

Given Text: I WILL BE BACK


String Text: ARNOLD

*Reading the matrix lexicologically according to the key and column wise
Encrypted Text- I_CLA_LB_WE_I_BK
DECRYPTION:

1. To decipher it, the recipient has to work out the column lengths by dividing the message length by the key length.
2. Then, write the message out in columns again, then re-order the columns by reforming the key word.
Code For Columnar Transposition Cipher
Caesar Cipher
A message encoded with the Caesar cipher
has a shift in its frequency analysis diagram
(equal to the selected shift) and a
coincidence index similar to the one of the
plain text.
Any reference to Caesar, emperor of Rome,
or more generally to antiquity and the
Roman Empire are clues.
Caesar Cipher: How it works..
It is a type of substitution cipher in
which each letter in the plaintext is
'shifted' a certain number of places
down the alphabet. For example,
with a shift of 1, A would be
replaced by B, B would become C,
and so on. The method is named
after Julius Caesar, who apparently
used it to communicate with his
generals
Code For Caesar Cipher
Thank You

You might also like