Compatibility with JAVA 1.6

  • smatte

    smatte - 2012-03-23

    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 !
    USE org.apache.commons.codec.binary.Base64

    The JAVA snippet for cipher usage still good.

    Thanks and, great work with that library!


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks