3 Replies Latest reply on Oct 6, 2011 10:31 AM by 802889

    java-oracle-java encryption-decryption error.

      We have a program which encrypts strings using DES and writes the encrypted to an oracle data. The code is similar to the following:
      private static String encrypt(String property) throws GeneralSecurityException {
      SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("PBEWithMD5AndDES");
      SecretKey key = keyFactory.generateSecret(new PBEKeySpec(PASSWORD));
      Cipher pbeCipher = Cipher.getInstance("PBEWithMD5AndDES");
      pbeCipher.init(Cipher.ENCRYPT_MODE, key, new PBEParameterSpec(SALT, 20));
      return base64Encode(pbeCipher.doFinal(property.getBytes()));

      This works consistently across jvms / os / hw / etc.

      Unfortunately, the original version was writing it to the db as strings and now, these can't be de-crypted as oracle returns different values from the column.

      I was wondering whether there was any way of retrieving these values now.



      Edited by: user10510492 on Sep 28, 2011 1:59 PM