Coding of Image and Text Encryption using AES, RSA, BLOWFISH and Hybrid

Coding

To accomplish the proposed program i.e. the web application, one of the most popular system life cycle approach prototype system life cycle approach has been user. This prototype is usually known for its effective approach with low time and cost. The main benefits of using this approach are that it improves the quality of work. For the development of the system the following backend and frontend system and other requirements has been used:

Interface: Html, CSS, Bootstrap, JavaScript’s

Backend: PostgreSql, Python (Django Framework)

Database: PostgreSql

Following are the list of backend file and interface file that has played important role for the complete looks of the system

For Authentication:

As authentication is one of feature provided by proposed system. Here we will discuss on how authentication process is carried out throughout the application.

Login page Template:

Login System function:

Here we can see we have created LoginF() function to accept user credential, after getting username and password it will further authenticate user sending username and password argument to another function authenticate.

If the credential is valid then it will return a user object and after getting user object the home page of specific user is response.

Dashboard:

Here we will illustrate dashboard view and how dashboard function is carried out throughout the application. The template and functional code of dashboard are presented below:

Dashboard Template:

Dashboard rendering function:

Here in the dashboard the homepage.html is render and the file list of the authenticated user is filtered and shown to the user. The “request.user” will return the actual login user and only his/her file will be available.

File encryption with AES:

Here we will illustrate how the AES method has been carried out and how AES encryption method has been coded and make it functional to any file. Here we will depict the View function and real function that is carried out by AES.

This is a rendering view of AES encryption, as we can see it will take file, its name and password for the encryption and the obtained arguments i.e. files and other arguments are than passed to a function EncryptNow()

It will again pass the file to another function that is encrypt_file and all the encryption process is carried out by this function after encrypting the file the real file will be deleted from server.

There are other function that are pad which will change data file any file to 16 byte boundary and after that it will generate a random block size of AES after that data is initialize by key and finally encrypted data is return.

File encryption with RSA

Here we will illustrate how the RSA method has been carried out and how RSA encryption method has been coded and make it functional to any file. Here we will depict the view function of the method and actual function that is carried out by RSA.

When user trigger for RSA encryptin the above view function is called the same method is applied while getting file, file name and its password.  To make it more simpler we have used one password for RSA encryption providing self-created public and private key.

We can see the class RSAEncryption() is playing vital role for the encryption of the file throughout the RSA method. There are different arguments that need to pass while calling the function they are public_key, private_key, public_key_passphrase and private_key_passphrase.

After providing required arguments to class the key will be generated of 2048 bit. It is very important for RSA to have public key param and private key param. Following are the default provided public and private key.

Public Key:

Private Key:

Now finally after getting public key and private key it will encrypt the real file that need to be encrypted and the following function take it path on the way of encrypting file through RSA method.

The output file is saved as “.enc” extension to provide more security and the file are encrypted and packed with different pad size, with the help of the struct to pack the file size and also AES is implemented to provide file byte so that any file can be encrypted.

File encryption with Blowfish

Here we will illustrate how the Blowfish method has been carried out and how Blowfish encryption method has been coded and make it functional to any file. Here we will depict the template file and function that is carried out by Blowfish.

The same process for taking file, its name and password is carried out here as well. When user trigger for blowfish encryption then the class BlowfishCipher() will be called out where we will pass the password set by the user and the within the object of the class we will pass the actual path of the file that needs to encrypt in a function encrypt_file()

The provided file is saved as “.enc” file and the file will be struct with the file size and then key and MODE_EAX are passed to the function. Finally writing file in encrypted format.

File encryption with Hybrid encryption method

Here we will illustrate how the hybrid encryption method has been carried out and how hybrid encryption method has been coded and make it functional to any file. Here we will depict the template file and function that is carried out by hybrid encryption.

The above code is trigger when user encrypts the file using Multi-encryption option. The same process of taking file, name and password is carried out after getting file and password, the object of the class HybridAESRSABlowFishCipher is created as we are using RSA as well it is an important task to provide public and private key. The same public and private key used for RSA Encryption is used here as well.

The new extension is added to the file “.enc” and the same file, the file is encrypted three times with different method. First the file will be encrypted with RSA method using it public and private key.

And then AES method is used to again encrypt the same file with same password.

\

And finally the same file is passed to Blowfish encryption

In this way the single file is passed to different method of encryption and the three encryption method has been used as hybrid encryption.

File Decryption:

For file decryption user can select their file and they need to provide password and the encryption method of the file that is used while encrypting file. Following is the template code for the decryption process of proposed application.

After selecting file and adding its password and choosing the method of encryption the file is passed to views and the decryption function is called based on the chosen decryption process.

 

Coding

To accomplish the proposed program i.e. the web application, one of the most popular system life cycle approach prototype system life cycle approach has been user. This prototype is usually known for its effective approach with low time and cost. The main benefits of using this approach are that it improves the quality of work. For the development of the system the following backend and frontend system and other requirements has been used:

Interface: Html, CSS, Bootstrap, JavaScript’s

Backend: PostgreSql, Python (Django Framework)

Database: PostgreSql

Following are the list of backend file and interface file that has played important role for the complete looks of the system

For Authentication:

As authentication is one of feature provided by proposed system. Here we will discuss on how authentication process is carried out throughout the application.

Login page Template:

Login System function:

Here we can see we have created LoginF() function to accept user credential, after getting username and password it will further authenticate user sending username and password argument to another function authenticate.

If the credential is valid then it will return a user object and after getting user object the home page of specific user is response.

Dashboard:

Here we will illustrate dashboard view and how dashboard function is carried out throughout the application. The template and functional code of dashboard are presented below:

Dashboard Template:

Dashboard rendering function:

Here in the dashboard the homepage.html is render and the file list of the authenticated user is filtered and shown to the user. The “request.user” will return the actual login user and only his/her file will be available.

File encryption with AES:

Here we will illustrate how the AES method has been carried out and how AES encryption method has been coded and make it functional to any file. Here we will depict the View function and real function that is carried out by AES.

This is a rendering view of AES encryption, as we can see it will take file, its name and password for the encryption and the obtained arguments i.e. files and other arguments are than passed to a function EncryptNow()

It will again pass the file to another function that is encrypt_file and all the encryption process is carried out by this function after encrypting the file the real file will be deleted from server.

There are other function that are pad which will change data file any file to 16 byte boundary and after that it will generate a random block size of AES after that data is initialize by key and finally encrypted data is return.

File encryption with RSA

Here we will illustrate how the RSA method has been carried out and how RSA encryption method has been coded and make it functional to any file. Here we will depict the view function of the method and actual function that is carried out by RSA.

When user trigger for RSA encryptin the above view function is called the same method is applied while getting file, file name and its password.  To make it more simpler we have used one password for RSA encryption providing self-created public and private key.

We can see the class RSAEncryption() is playing vital role for the encryption of the file throughout the RSA method. There are different arguments that need to pass while calling the function they are public_key, private_key, public_key_passphrase and private_key_passphrase.

After providing required arguments to class the key will be generated of 2048 bit. It is very important for RSA to have public key param and private key param. Following are the default provided public and private key.

Public Key:

Private Key:

Now finally after getting public key and private key it will encrypt the real file that need to be encrypted and the following function take it path on the way of encrypting file through RSA method.

The output file is saved as “.enc” extension to provide more security and the file are encrypted and packed with different pad size, with the help of the struct to pack the file size and also AES is implemented to provide file byte so that any file can be encrypted.

File encryption with Blowfish

Here we will illustrate how the Blowfish method has been carried out and how Blowfish encryption method has been coded and make it functional to any file. Here we will depict the template file and function that is carried out by Blowfish.

The same process for taking file, its name and password is carried out here as well. When user trigger for blowfish encryption then the class BlowfishCipher() will be called out where we will pass the password set by the user and the within the object of the class we will pass the actual path of the file that needs to encrypt in a function encrypt_file()

The provided file is saved as “.enc” file and the file will be struct with the file size and then key and MODE_EAX are passed to the function. Finally writing file in encrypted format.

File encryption with Hybrid encryption method

Here we will illustrate how the hybrid encryption method has been carried out and how hybrid encryption method has been coded and make it functional to any file. Here we will depict the template file and function that is carried out by hybrid encryption.

The above code is trigger when user encrypts the file using Multi-encryption option. The same process of taking file, name and password is carried out after getting file and password, the object of the class HybridAESRSABlowFishCipher is created as we are using RSA as well it is an important task to provide public and private key. The same public and private key used for RSA Encryption is used here as well.

The new extension is added to the file “.enc” and the same file, the file is encrypted three times with different method. First the file will be encrypted with RSA method using it public and private key.

And then AES method is used to again encrypt the same file with same password.

\

And finally the same file is passed to Blowfish encryption

In this way the single file is passed to different method of encryption and the three encryption method has been used as hybrid encryption.

File Decryption:

For file decryption user can select their file and they need to provide password and the encryption method of the file that is used while encrypting file. Following is the template code for the decryption process of proposed application.

After selecting file and adding its password and choosing the method of encryption the file is passed to views and the decryption function is called based on the chosen decryption process.