I encrypt a message and then decrypt it. Here is the gist: https://gist.github.com/2489899.
I have to store this keys in a xml scheme, because the message should be able to decrypt in c# too. (This is only a “summary” of my program with the databse and so on). But i always get the 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)
Simple, your RSAPrivateCrtKeySpec constructor call uses an incorrect order of parameters.