2. 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.
3. 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.
4. Encryption
Encryption is the process of converting readable data
(called the plaintext) into a form which hides its
content, called the ciphertext.
Decryption
Decryption is the reverse process, with a ciphertext
converted back into the corresponding plaintext.
5. 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.
6. 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.
7. In general the security of encrypted data is
dependent on two factors:
1. The strength of the cipher.
2.The secrecy of the key.
9. Affine Cipher
The affine cipher is a type of monoalphabetic
substitution cipher, wherein each letter in an alphabet is
mapped to its numeric equivalent, encrypted using a
simple mathematical function, and converted back to a
letter.
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 b
are the key of the cipher. The value a must be chosen
such that a and m are coprime.
Also, 0 ≤ a < m, and 0 ≤ b < m
10. 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.
11. Algorithms
Encryption :
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).
12. 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.
13. 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.
14. 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
16. SystemRequirements
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
17. 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.