Compatibility with JAVA 1.6

Help
smatte
2012-03-23
2012-12-11
  • smatte
    smatte
    2012-03-23

    Hi,
    I'm trying to use pidCrypt to encrypt a message and send it to a java server that will decrypt it.

    What I'm doing is:

    Cipher cipher = Cipher.getInstance("RSA/1/PKCS1PADDING", "BC");
    cipher.init(Cipher.DECRYPT_MODE, privKey);
    String message = new String(cipher.doFinal(encryptedMessage));
    

    I'm getting:

    javax.crypto.BadPaddingException: unknown block type
    at org.bouncycastle.jce.provider.JCERSACipher.engineDoFinal(Unknown Source)
    at javax.crypto.Cipher.doFinal(DashoA13*..)

    What I'm doing wrong? Is it compatible with pidCrypt? Thanks for any idea!

     
  • smatte
    smatte
    2012-03-27

    Thanks for the advise. I finally found my error. There was a mismatch between your base64 encoding and the one I was using  in java.

    DO NOT USE com.google.gwt.user.server.Base64Utils !
    USE org.apache.commons.codec.binary.Base64

    The JAVA snippet for cipher usage still good.

    Thanks and, great work with that library!