Top Banner
ENCRYPTION-DECRYPTION of Devanagri Script Using Affine Cipher Team : Astha Goel Harshit Bhatia Mohit Singhal Prachi Gupta Swati Nagpal Deen Dayal Upadhaya College
18

Encryption/Decryption Algorithm for Devanagri Script(Affine Cipher)

Jul 15, 2015

Download

Software

Swati Nagpal
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Encryption/Decryption Algorithm for Devanagri Script(Affine Cipher)

ENCRYPTION-DECRYPTIONof Devanagri Script Using Affine Cipher

Team :

Astha Goel

Harshit Bhatia

Mohit Singhal

Prachi Gupta

Swati NagpalDeen Dayal Upadhaya College

Page 2: Encryption/Decryption Algorithm for Devanagri Script(Affine Cipher)

Objective

To design and implement an Encryption/Decryption scheme based on affine cipher for plain text in Devanagri(Unicode) communicating message in Hindi.

Also, to develop a solver which solves the crypt when the encryption parameters(key) are not known.

Page 3: Encryption/Decryption Algorithm for Devanagri Script(Affine Cipher)

Introduction

CRYPTOGRAPHY

Cryptography, derived from Greek words

krptos- secret and graphy- writing.

It is the science of using mathematics to hide information.

With the help of Cryptography we can store sensitive information, or transmit it over insecure networks (such as the internet) so that it can only be read by the intended recipient.

Page 4: Encryption/Decryption Algorithm for Devanagri Script(Affine Cipher)

EncryptionEncryption is the process of converting readable data

(called the plaintext) into a form which hides itscontent, called the ciphertext.

DecryptionDecryption is the reverse process, with a ciphertext

converted back into the corresponding plaintext.

Page 5: Encryption/Decryption Algorithm for Devanagri Script(Affine Cipher)

NOTE:

Cryptography should not be confused with encryption. The name encryption itself defines the basic difference. EN-CRYPT: “en” means to make and “crypt or crypto” means hidden or secret. Hence, Encryption is a fundamental tool for protection of information while Cryptography is the method of transforming the representation of information for secured transmission of information.

Page 6: Encryption/Decryption Algorithm for Devanagri Script(Affine Cipher)

Ciphers

A cipher is a mathematical function used in the encryption and decryption processes. Most ciphers use a secret key when encrypting, and different keys will typically encrypt a given plaintext into different ciphertexts.

The key is usually only known by the person who encrypts the data, and the intended recipient. The secrecy of the key ensures that even if an eavesdropper were to intercept the transmitted data, they would be unable to decrypt it.

Page 7: Encryption/Decryption Algorithm for Devanagri Script(Affine Cipher)

In general the security of encrypted data is dependent on two factors:

1. The strength of the cipher.2. The secrecy of the key.

Page 8: Encryption/Decryption Algorithm for Devanagri Script(Affine Cipher)

Classes Of Cipher

Affine Cipher

Page 9: Encryption/Decryption Algorithm for Devanagri Script(Affine Cipher)

Affine CipherThe affine cipher is a type of monoalphabeticsubstitution cipher, wherein each letter in an alphabet ismapped to its numeric equivalent, encrypted using asimple mathematical function, and converted back to aletter.

Each letter is enciphered with the function ,

E(x)=(ax+b) (mod m)where modulus m is the size of the alphabet and a and bare the key of the cipher. The value a must be chosensuch that a and m are coprime.

Also, 0 ≤ a < m, and 0 ≤ b < m

Page 10: Encryption/Decryption Algorithm for Devanagri Script(Affine Cipher)

The decryption function is:

D(x) = a-1(x-b) mod{m}

Where a-1 is the modular multiplicative inverse of a modulo m, i.e. it satisfies the equation:

1=aa-1 mod{m}

Special Cases:

The Caesar Cipher is the Affine cipher when since the encrypting function simply reduces to a linear shift ie. when a=1.

The Decimation Cipher is the Affine cipher when the encryption function reduces to (ax)MOD m as the value of b=0.

Page 11: Encryption/Decryption Algorithm for Devanagri Script(Affine Cipher)

AlgorithmsEncryption :

The value of the appropriate key (ie. Fulfilling the condition of the affine cipher), and the plaintext in devanagri is asked from the user.

The characters from plaintext are mapped according to the encryption function. The mapped characters are then printed in the encrypted file using FileUtils class (provided by Apache).

Decryption :

The values of a & b for the decryption function, and the encrypted file are asked from the user.

The pre-image of the characters is hence found and printed in the decrypted file using FileUtils class( as done in Encryption).

Page 12: Encryption/Decryption Algorithm for Devanagri Script(Affine Cipher)

Algorithms

Key Calculation :

Take any two random characters (x1,x2) from plaintext and the corresponding mapped characters(y1,y2) from ciphertext.

CASE- 1 : SOLVING THE SYSTEM OF LINEAR EQUATIONS

(x1, x2 has both odd and even unicodes )

I. Form the equations in terms of a & b by substituting the values of x & y in the encryption function.

II. We have 2 variables and 2 equations. Solving the equations, we get the values of a & b.

Page 13: Encryption/Decryption Algorithm for Devanagri Script(Affine Cipher)

CASE - 2 BRUTE FORCE

(when both x1 and x2 have even OR odd unicodes only)

I. For all possible values of a( ie. All the co-primes of m less than the value of m), we check for all the values of b, satisfying the encryption function.

II. Then this encryption function is checked for the rest of the file text. If it matches with the rest of the file, the values for a & b are returned.

III. Otherwise the value of a & b are discarded and the steps I and II are repeated again and again till the time a consistent value of key(that matches the key of the rest of the file) is not found.

Note: In this case, more than 1 unique solution is possible.

Page 14: Encryption/Decryption Algorithm for Devanagri Script(Affine Cipher)

Time-Complexity

Encryption: O(n)

Decryption: O(n)

Key Calculation:

* Best Case: O(n)/O(1)cz it is not not dependent on the file

size now

* Worst Case: O(m2n)

where m = 128,

n = no. of characters in original file

Page 15: Encryption/Decryption Algorithm for Devanagri Script(Affine Cipher)

Space-Complexity

Encryption: O(1) Decryption: O(1)

Key Calculation: O(n)where n = no. of characters in original file

Page 16: Encryption/Decryption Algorithm for Devanagri Script(Affine Cipher)

System Requirements

SOFTWARE REQUIREMENTS Java Development Kit 1.6 (jdk 1.6) or more

Java Runtime Environment

Platform (IDE) (for running source code): NetBeans IDE 7.0.1

MEMORY REQUIREMENTS

Software: 500 KB

Implementation Software and Platform: 1 GB

Page 17: Encryption/Decryption Algorithm for Devanagri Script(Affine Cipher)

Conclusion

The key of the affine cipher can be uniquely found with just 2 characters from the plaintext and the corresponding mapped characters from the ciphertext provided the characters have odd and even unicodes.

But if unicodes of both the characters are even or odd(which is somewhat a rare case), we need to compare the different combinations of key with the rest of the text to obtain single unique key for the entire text.

Page 18: Encryption/Decryption Algorithm for Devanagri Script(Affine Cipher)

References

Websites :

http://en.wikipedia.org/wiki/Affine_cipher http://www.johndcook.com/blog/2008/12/10/solving

-linear-congruences/ http://www.math.sunysb.edu/~scott/Book331/Affine

_enciphering.html http://www.engineersgarage.com/articles/what-is-

cryptography-encryption?page=1 http://www.javaranch.com http://cryptointro.wordpress.com