0% found this document useful (0 votes)
10 views4 pages

Practical No. 2-Is

The document outlines a practical exercise to implement encryption and decryption using the Data Encryption Standard (DES) algorithm in Java. It provides a brief history of DES, its development, and its security features, as well as a sample Java program demonstrating the encryption and decryption process. The conclusion emphasizes the importance of using CipherOutputStream and CipherInputStream for handling encrypted data.

Uploaded by

nrasika1122
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views4 pages

Practical No. 2-Is

The document outlines a practical exercise to implement encryption and decryption using the Data Encryption Standard (DES) algorithm in Java. It provides a brief history of DES, its development, and its security features, as well as a sample Java program demonstrating the encryption and decryption process. The conclusion emphasizes the importance of using CipherOutputStream and CipherInputStream for handling encrypted data.

Uploaded by

nrasika1122
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

PRACTICAL NO.

2
Title: Write a Java/C/C++/Python program to perform encryption and decryption using the
method of Transposition technique.

DES stands for Data Encryption Standard. It is a symmetric-key block


cipher algorithm used to encrypt and decrypt data. It is developed by the IBM team in early
1970. It accepts the plaintext in 64-bit blocks and changes it into the ciphertext that uses the
64-bit keys to encrypt the data. The algorithm uses the same key to encrypt and decrypt the
data.
It is based on LUCIFER (also known as Feistel block cipher algorithm) which is a direct
predecessor of the DES algorithm. It is developed by eminent scholar and researcher Horst
Feistel at IBM. It provides high security by using a 128-bit key block and a 128-bit block size.
The DES algorithm uses the 16 rounds of the Feistel structure. The structure uses a unique key
for each round. Finally, in 1976, it was approved by the federal encryption standard.
Program:
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.KeyGenerator;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKey;
public class DES
{
public static void main(String[] args)
{
try{
System.out.println("Message Encryption Using DES Algorithm\n-------");
KeyGenerator keygenerator = KeyGenerator.getInstance("DES");
SecretKey myDesKey = keygenerator.generateKey();
Cipher desCipher;
desCipher = Cipher.getInstance("DES/ECB/PKCS5Padding");
desCipher.init(Cipher.ENCRYPT_MODE, myDesKey);
byte[] text = "Secret Information ".getBytes();
System.out.println("Message [Byte Format] : " + text);
System.out.println("Message : " + new String(text));
byte[] textEncrypted = desCipher.doFinal(text);
System.out.println("Encrypted Message: " + textEncrypted);
desCipher.init(Cipher.DECRYPT_MODE, myDesKey);
byte[] textDecrypted = desCipher.doFinal(textEncrypted);
System.out.println("Decrypted Message: " + new
String(textDecrypted));
}catch(NoSuchAlgorithmException e){
e.printStackTrace();
}catch(NoSuchPaddingException e){
e.printStackTrace();
}catch(InvalidKeyException e){
e.printStackTrace();
}catch(IllegalBlockSizeException e){
e.printStackTrace();
}catch(BadPaddingException e){
e.printStackTrace();
}
}
}
Output:
Conclusion:
We conclude that the basic steps of the algorithm are: At last, write and read the
encrypted or decrypted data by using the CipherOutputStream and CipherInputStream. Let's
implement the DES algorithm in a Java program and see how data is encrypted and decrypted
using the algorithm.

You might also like