Encryption is a very useful technique when it comes to preserving confidentiality of data/information.
Back in the days people ( specially military guys ) wanted a strong method to make their information readable only to an intended party. Why I purposely mentioned "a strong method" because even Caesar had a method to do this. We call it Caesar cipher. But it was not strong enough. We can get into details about these technique later. Before that let's get a clear idea about encryption and decryption.
figure 1:
figure 2:
As you can see, in figure 1 outsider can read the message and in figure 2 he cannot. How that happened? This is where encryption comes.
Encryption : The process of converting plain text (readable format) into cipher text (unreadable format).
Decryption : The process of converting cipher text into plain text.
Terminologies
Cipher : In cryptography, a cipher (or cypher) is an algorithm for performing encryption or decryption.
Key : is a string of bits used by a cryptographic algorithm to transform plain text into cipher text or vice versa.
Transposition Cipher : A character is shifted pre-agreed number (key) of times according to a regular system. The order of characters is changed (cipher text).
Substitution Cipher : In cryptography, a substitution cipher is a method of encoding by which units of plaintext are replaced with ciphertext, according to a fixed system; the "units" may be single letters (the most common), pairs of letters, triplets of letters, mixtures of the above, and so forth.
Types of Encryption
1. Symmetric encryption - A single key is used for both encryption and decryption processes.
2. Asymmetric encryption - Key pair ( public key & private key ) is used for encryption and decryption. If private key is used for encryption public key of the same key pair must be used for decryption. If public key is used for encryption private key of the same key pair must be used for decryption.
Symmetric encryption algorithms : AES, DES, 3DES
Asymmetric encryption algorithms : DSA, Elliptic curve, RSA, Diffie-Hellman
I have implemented a software which uses AES 128 bit algorithm to encrypt files in our computer. This software supports for text files and PDF files only.
This is the Github link which contains the source code. All the instructions are there in the Readme file.
https://github.com/sajith01prasad/Encryption-Decryption
IDE used- NetBeans 8.1
Language used - Java
Jar file is provided. Go to this GitHub link and download the jar file. Readme file is there if you need any help with setting it up locally.
Once the jar file is downloaded, open up a command prompt. This is how you run a java application using cmd.
Now you will see the application running.
As you can see you can provide a text file, PDF file or a folder which contains multiple text files and multiple PDF files. Browse button will help you to browse the file you need and upload it to the application. In java you have JFileChooser class for this feature.
Browse a text file
In my desktop I have a text file called "Original.txt". You also make one.
Now click on "Encrypt" button in the application interface. Now open the file.
It is encrypted. To decrypt this and get the original content again click on "Decrypt" button. Then open the file again.
(2) PDF
Browse a PDF file
I have a pdf file called "test.pdf" in my desktop. You also make one and browse it.
Now click on "Encrypt" button and open the file.
It is encrypted. Let's decrypt this now. click on "Decrypt" button and open the file.
It is decrypted . 😊
(3) Folders
In my desktop I have a folder called "testingFolder".
In that I have to text files (original.txt, original1.txt ) and one PDF file ( testPDF).
Original.txt
Original1.txt
testPDF.pdf
Now browse this folder.
Now click on "Encrypt" button. Open the files to see whether they are encrypted or not.
Original.txt
Original1.txt
testPDF.pdf
Note : Do not compare encrypted values even though the content(original value) is same. Because in the code I generate a random string as a key for encryption. So encrypted value may not be same even though the original content is same.
Now click on "decrypt" to get original contents back.
I hope you enjoyed this blog post and learnt something. Comment section is open if you have any question regarding to this topic. Cheers !!!
hey nice work ! :) can u share the coding for this project? would be helpful if can see the code. thanks :)
ReplyDeletehttps://github.com/sajith01prasad/Encryption-Decryption
Delete