Write the RC4 logic in Java Using Java cryptography; encrypt the text “Hello world” using Blowfish. Create your own key using Java key tool.
HARDWARE
AND SOFTWARE REQUIREMENT:
1. Intel based Desktop PC: - RAM of 512 MB
2. Notepad/Notepad ++ editor and Command Prompt or
3. IntelliJ IDEA Community Edition
THEORY:
Ø
RC4– this algorithm is used
to create pseudo-random stream of bits (a
key-stream). As with any stream cipher, keystreams can be used for encryption
Ø
A stream cipher is
a symmetric key cipher where plaintext digits one at a time are XORed
with corresponding digits of pseudorandom stream of bits (keystream)
to create encrypted message i.e. ciphertext.
Ø
RC4 is mostly used in protocols
such as :
1) Secure
Socket Layer (SSL) to establish an encrypted
link between a web server and a browser to ensure all data transmitted remain private and generally used by many
websites to protect their online transaction with their customers
2) Wired
Equivalent Privacy (WEP) security protocol to provide security and privacy to
wireless networks(e.g. Wi-Fi) comparable to as in Wired Network (LAN)
Ø
Blowfish is
also an encryption technique which is replacement to DES algorithm and that
is very powerful ammunition against hackers and cyber-criminals. It
is utilized in a wide array of products like in performance-constrained
environments such as embedded systems, secure E-mail encryption tools, backup
software, password management tools.
SOURCE
CODE:
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import javax.swing.JOptionPane;
public class BlowFishCipher{
public static void main(String[]args) throws Exception{
//create a keygenerator based upon the
KeyGenerator keygenerator= KeyGenerator.getInstance("Blowfish");
//create a key
SecretKey secretkey=keygenerator.generateKey();
//create a cipher based upon Blowfish
Cipher cipher=Cipher.getInstance("Blowfish");
//initialise cipher to with secretkey
cipher.init(Cipher.ENCRYPT_MODE,secretkey);
//get the text to encrypt
String inputText = "Hello world";
//encrypt message
byte[] encrypted=cipher.doFinal(inputText.getBytes());
//re-initialise the cipher to be in decrypt mode
cipher.init(Cipher.DECRYPT_MODE,secretkey);
//decrypt message
byte[] decrypted=cipher.doFinal(encrypted);
//and display the results
System.out.println("Original String: " + inputText);
System.out.println("Encrypted: " + new String(encrypted));
System.out.println("Decrypted: " + new String(decrypted));
}
}
OUTPUT:
VIVA QUESTIONS:
1. What is JAVA?
2. What is BlowFish Algorithm?
3. What is Cryptography?
4. What is Encryption?
5. What is Decryption?
6. What is RC4 Logic?
The content you posted that is related to technology is good. I expect more information from you like this.
ReplyDeleteWordpress Training in Chennai
Wordpress Training institute in Chennai
Wordpress Training Chennai
Wordpress Training in Porur
Struts Training in Chennai
Struts Training
Spring Training in Chennai
Hibernate Training in Chennai