Question

I am migrating from JDK 1.5 to JDK 1.6. I've encountered difficult problem. Here is piece of code:

SecretKeyFactory factory = SecretKeyFactory.getInstance("PBEWithMD5AndTripleDES");
SecretKey key = factory.generateSecret(keySpec);
Cipher ecipher = Cipher.getInstance(key.getAlgorithm());

The created Cither instances produce different results for JRE 1.5 and JRE 1.6 (jce is installed in both cases).

Why JDKs produce different results? What is the difference in java security implementation between versions 1.5 and 1.6?

Was it helpful?

Solution 2

This works for both JDK 1.5 and JDK 1.6

        SecretKeyFactory factory = SecretKeyFactory.getInstance("PBEWithMD5AndTripleDES");
        SecretKey key = factory.generateSecret(keySpec);

        // instead of key.getAlgorithm(). For compatibility with JDK 1.5
        String newAlgorithm = "PBEWithMD5AndDES"; // the same value as in JDK 1.5

        ecipher = Cipher.getInstance(newAlgorithm);

OTHER TIPS

Here is a link to the differences between 1.5 & 1.6:

http://en.wikipedia.org/wiki/Java_6#Java_SE_6_.28December_11.2C_2006.29

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top