Decryption and encryption of Java RSA using C #

I encrypt the message and then decrypt it. Here is the gist: https://gist.github.com/2489899 . I have to store these keys in an xml scheme, because the message must also decrypt in C #. (This is just a "summary" of my program with a dam, etc.). But I always get an exception:

javax.crypto.BadPaddingException: Data must start with zero
at sun.security.rsa.RSAPadding.unpadV15(RSAPadding.java:308)
at sun.security.rsa.RSAPadding.unpad(RSAPadding.java:255)
at com.sun.crypto.provider.RSACipher.a(DashoA13*..)
at com.sun.crypto.provider.RSACipher.engineDoFinal(DashoA13*..)
at javax.crypto.Cipher.doFinal(DashoA13*..)
at Main.decrypt(Main.java:50)
at Main.main(Main.java:24)
+3
source share
2 answers

Simple, your call to the RSAPrivateCrtKeySpec constructor uses the wrong order of parameters.

+1
source

JavaDoc sun.security.rsa.RSAPadding javax.crypto.BadPaddingException, , Java- PKCS # 1 v1.5 padding, C- . , , , .

+2

All Articles