Check that you have correctly exchanged the key.
Check that you have correctly exchanged the key. Trying to decrypt with an incorrect key is indistinguishable from decrypting badly padded data.
I'm working through a similar problem operating between . Net and iPhone stuff in Objective - C, and I think the answer lies in this little gem from the RSACryptoServiceProvider documentation: Unlike the RSA implementation in unmanaged CAPI, the RSACryptoServiceProvider class reverses the order of an encrypted array of bytes after encryption and before decryption. By default, data encrypted by the RSACryptoServiceProvider class cannot be decrypted by the CAPI CryptDecrypt function and data encrypted by the CAPI CryptEncrypt method cannot be decrypted by the RSACryptoServiceProvider class.
See here for more details: http://msdn.microsoft.com/en-us/library/s575f7e2(v=VS.90).aspx.
My guess is that the C# version is emitting the bytes in little endian format, and the Java version is importing the bytes expecting them to be in big endian format. Try swapping the bytes in baRet from end to end before you convert them to base 64, and see if your Java program can decrypt them then. Just a guess.
I had exactely the same problem and I finally find the solution! I was stubborn using PKCS1Padding but I didn't manage to make it work. The best result I got using "rsa.
Encrypt(baIn, false)" on the C# side and "RSA/NONE/NoPadding" on the Java side was this kind of string : "☻? O+_>?5? L0Q*?
*? Râ–²? ™€7..." followed by my decrypted string.So in a way it got decrypted but since there is no padding specified, the data is shifted.
So I tried all the paddings available in bouncycastle but I would alway get errors such as "block incorrect size" or "data hash wrong". So I decided to start trying OAEP paddings and I finally managed to get it working by using "rsa. Encrypt(baIn, true)" on the C# side and "RSA/NONE/OAEPWithSHA1AndMGF1Padding" on the java side!
It worked for me, I hope it will work for you too! If it doesn't work make sure you're using the right key, very often the problem comes from the key.
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.