Coders Packet

Java project for Encryption and Decryption a text file.

By Paras Saini

In this Java project, I have implemented DES(Data Encryption Standard) algorithm for encrypting a text file. After encrypting you can decrypt your file again.

Introduction:-

This project is for security purposes, in this project you can encrypt your text file and again decrypt it. In this project, we have used the DES algorithm and cipher concept for encryption.

Algorithm:-

This project is based on DES(Data Encryption Standard) which is implemented by using JCF(Java Collection Framework).

Data encryption standard (DES) has been found vulnerable against very powerful attacks and therefore, the popularity of DES has been found slightly on the decline.

DES is a block cipher and encrypts data in blocks of size of 64 bits each, which means 64 bits of plain text goes as the input to DES, which produces 64 bits of ciphertext. The same algorithm and key are used for encryption and decryption, with minor differences. The key length is 56 bits.

Cipher Text:-

In cryptography, ciphertext or cyphertext is the result of encryption performed on plaintext using an algorithm, called a cipher. The ciphertext is also known as encrypted or encoded information because it contains a form of the original plaintext that is unreadable by a human or computer without the proper cipher to decrypt it. This process prevents the loss of sensitive information via hacking. Decryption, the inverse of encryption, is the process of turning ciphertext into readable plaintext. The ciphertext is not to be confused with code text because the latter is a result of a code, not a cipher.

Java Collection Framework:-

Java collection Framework or JCF is the predefined packages, classes, and interface in Java which has various advantages we can use them by using only one key called import package_name.class_name. 

Due to these framework Java is very popular language.

Some classes pf JCF used in this project:-

import java.io.*; // * implement all classes of io package

import java.util.Scanner;

/*import java.io.FileInputStream;

import java.io.FileOutputStream;

import java.io.IOException;

import java.io.InputStream;

import java.io.OutputStream;

import java.security.InvalidAlgorithmParameterException;

import java.security.InvalidKeyException;*/

import java.security.NoSuchAlgorithmException;

import java.security.SecureRandom;

import java.security.spec.InvalidKeySpecException;

import java.security.*;

import javax.crypto.SecretKey;

import javax.crypto.SecretKeyFactory;

import javax.crypto.spec.DESKeySpec;

import javax.crypto.spec.IvParameterSpec; import javax.crypto.*;

Class:-

There is only one class used in this package called EncryptionDecryption having all the functionality and methods in it.

Demo:- 

For encryption enter choice 1:

For decryption enter choice 2:

To have a demo of this project first you need to make two text files one has plain text in it and the other is a blank text file then you need to paste the path of these files in the below line of the program for encryption:-

 File textfile = new File("file path/file name"); //path of file that have plain text

 File encrypted1 = new File("file path/file name"); //path of blank text file which is empty

You receive the message "encryption complete" when encryption gets completed.

You receive the message "decryption complete" when decryption is complete.

To decrypt a file you need to enter choice as 2 then you need to paste the path of your text file in the below lines of code.

 

File encrypted2=new File("PAth"); //this is the same file where encyption happend

File decrypted=new File("Path"); //this is the new file which have decrypted message

Note:-

Before applying a description you need to encrypt a file.

Download project

Reviews Report

Submitted by Paras Saini (paras2991)

Download packets of source code on Coders Packet