J2ME AES Decryption Error(org.bouncycastle.crypto.InvalidCipherTextException: pad block corrupted)?

The line String cipherString = new String(cipherBytes); is a bug. CipherBytes is a byte array with arbitrary values and cannot be converted to a string using any of the Java string decoders. You should just send/save the cipher as a byte array.

If you must make it a string then you'll have to use an encoder. Base64 encoders are often used, as are Base16 (hex). You can use the Apache Commons Codec or my favorite, the Harder Base64 codec.

Any base64 coder that still outputs bytes instead of characters is a bit idiotic in my opinion. I can already see the horror when somebody tries to stream it to an UTF-16 XML file. Also, it does not seem to support any other forms of base64 than the default one.

Mmm, maybe I should make my encoder available as well. – owlstead Jul 21 at 23:39 @owlstead: I agree. The Harder codec will output strings as well as support the idiotic Apache commons style.

– GregS Jul 22 at 0:51.

I found the problem I have check same application on my fedora its working perfect there is no problem in code but it makes different result in Windows os I am not sure but this may be problem with my IDE's windows version.

Nope, you have assigned yourself the answer too quickly. It's the different character encoding used in String. Never ever use the String(byte) constructor unless you are sure you will read the String back on the same operating system.

Other than that, follow the answer given by GregS as it is actually the correct one. – owlstead Jul 21 at 23:34 @owlstead you are right my friend.. – Mihir Jul 22 at 5:27.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions