Thursday, April 6, 2017

Encryption with Shared key

Hi 😍, after a few weeks I came again to give new flavor of term related to security.


Yup buddy, hope you will all have privacy and confidentiality things in your laptop or PC.πŸ˜πŸ™ˆπŸ™ˆ

It is kind of .txt file,.pdf file,.jpg file,.png file or other.

It is very important to you and you don’t want to see any unauthorized people access your file also. 

Then how can you protect those kind of files which are included more valuable data.

 No need to worry anymore because now we have a solution to get away from it.

Hmmm πŸ’¬ok before come to this point, I have to explain some terms cognate to this. 
Otherwise you will tell “what the fiddlesticks is this?”πŸ˜₯


   Cryptography -Is a Practices and studies of transforming                                readable information into unreadable format.
    Plain text - Readable data
    Cipher text Encrypted data (unreadable data)

So the process is we convert our readable (plaintext) file in to unreadable (cipher text) format. And we call this process as cryptography.

By the way using cryptography we can provide confidentiality,integrity,authenticity to the data. But in this blog I am going to do little stuff cognate to confidentiality. We can do encryption process in two ways:

  • Asymmetric Encryption - Also known as public key cryptography, uses public and private keys to encrypt and decrypt data.
                   Ex:RSA,EIGamal,elliptic,curves,DH.
  • Symmetric Encryption - That use the same cryptographic keys for both encryption of plaintext and decryption of cipher text.
                  Ex: DES, 3DES, AES, IDEA, RC2/4/5/6, Blowfish.

And now I am using Symmetric Encryption for encrypting files. In here I have used AES as my encryption algorithm used Java as my coding language and this code you can download or clone in my GitHub account, this is my URL.


https://github.com/pamoda-perera/symmetric

Open your IDE and create project.





This is what I have done in cording part.

Here’s a CryptoUtilits class that provides two utility methods, one for encrypt a file and another for decrypt a file:









Both the methods encrypt() and decrypt() accept a key, an input file and an output file as parameters, and throws a CryptoException which is a custom exception written as below:



The following codes are written for a test class that tests the CryptoUtils class above:


























Using above cord you can have a clear idea how it works. 

How to do......

What you have to do is first create file with including data.


Then run this interface select that created file and click encrypt button. 



Then enter valid key size and select the file which you want to encrypt. 


Now you can see there is file call with .encrypted extension.

This is what you can see after encryption the .txt file,the thing which are in here can't read anyone.


 Now please move original file into other place otherwise you can’t see difference of decrypted file.

Then again run that interface and choose encrypted file and click decrypted button. 


showing the decryption successful message....




Now you will be able to encrypted file and decrypted file at in the same location, and your original file has not been changed.


It stays as it is.πŸ˜ƒand you get the original data....


Habitually I did this as my knowledge, if there is any mistake please give your feedback as comment.

I am glad to bestow this article, because now you know how to protect your personal data from unauthorized access.

See ya n catch u later from a new episode…….

Thank you,πŸ˜ƒπŸ˜ƒ
Best regards,
Pamoda .P Perera.



4 comments: