i have got a problem with RSA en-/decryption. following simple example uses the public key from the keypair for encryption, and the private key for decryption. sometimes it works and sometimes there's a badpaddingexcpetion trown. i searched the internet about this problem but didn't find any working solution. perhaps, this is bug? i hope you can help me. here comes the code:
"Wenn man irgendwann mal von allen akzeptiert wird, dann weiß man, dass man irgendwas falsch gemacht hat." Excerpt by: Mr. Weidner
Andreas Pax Lück
Joined: Nov 04, 2009
i tried to use a byte array for the message (not string) and now it works. this helps me. but do you have any idea why the string conversion destroys the encryption?
Encrypted stuff is binary data, not character data, so it can't be meaningfully converted to a String. If for some reason you need an ASCII representation of something that's encrypted (maybe for storing it in a text-only database field), then you should run it through an encoding like base-64.
Ping & DNS - updated with new look and Ping home screen widget