Help required on Java Encryption
I am using following code on jdk131_08,JCE1.2.2getting following error
java.security.NoSuchAlgorithmException: Cannot find any provider supporting Blowfish
at javax.crypto.Cipher.getInstance(DashoA6275)
at CipherTest.encrypt(CipherTest.java:32)
at CipherTest.main(CipherTest.java:23)
Exception in thread "main"
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.SecretKeySpec;
publicclass CipherTest{
privatestaticfinalchar[] hexDigits ={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
publicstatic String encryptionKey ="dmt";
publicstatic String encryptionType="Blowfish";
publicstaticvoid main(String[] args)throws InvalidKeyException, BadPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException, NoSuchPaddingException, NoSuchMethodException
{
encrypt();
}
publicstaticvoid encrypt()throws NoSuchMethodException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException, NoSuchPaddingException{
SecretKeySpec secretKey =new
SecretKeySpec(encryptionKey.getBytes(), encryptionType);
// KeyGenerator generator= KeyGenerator.getInstance("DES");
//generator.init(new SecureRandom());
Cipher cipher = Cipher.getInstance(encryptionType);
cipher.init(Cipher.ENCRYPT_MODE, secretKey,new SecureRandom());
String input ="Ramesh";
byte[] inputBytes = input.getBytes();
byte[] ciphered = cipher.doFinal(inputBytes);
System.out.println(byteToHex(ciphered));
}
publicstatic String byteToHex(byte[] b){
StringBuffer h =new StringBuffer();
for (int i = 0; i < b.length; i++){
int k = b[i];
h.append(hexDigits[(k >>> 4) & 0x0F]);
h.append(hexDigits[k & 0x0F]);
}
return h.toString();
}
}

