Java Implementing BlowFish Algorithm

 Implementing BlowFish Algorithm:

Code:
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
public class BlowFishCipher
{
public static void main(String[] args)throws Exception
{
KeyGenerator keygen=KeyGenerator.getInstance("Blowfish");
SecretKey sk=keygen.generateKey();
Cipher cip=Cipher.getInstance("Blowfish");
cip.init(Cipher.ENCRYPT_MODE,sk);

String inputText="Hello";
byte[] encrypted=cip.doFinal(inputText.getBytes());

System.out.println("Encrypted :"+new String(encrypted));
cip.init(Cipher.DECRYPT_MODE,sk);

byte[] decrypted=cip.doFinal(encrypted);
System.out.println("Decrypted :"+new String(decrypted));
System.exit(0);
}
}


Learn More :

Learn More Multiple Choice Question :