Problems encrypting a String using RSA algorithm in Java?

Encrypted message is an arbitrary byte it's not guaranteed that it can be correctly converted to String with particular character encoding, so there is no need to convert it to String.

Encrypted message is an arbitrary byte, it's not guaranteed that it can be correctly converted to String with particular character encoding, so there is no need to convert it to String. Another trick is that plaintext should be less than n, otherwise algorithm would produce garbage. When this condition is met, it works fine for me.

Yet another possible problem is that when the first byte of message in greater or equal than 0x80, a negative plaintext would be produced. It can be solved by prepending a zero byte to the bytes of message before converting it to BigInteger, and stripping that byte during inverse conversion.

Thanks! I'll try it. – Egor Apr 29 at 9:15.

It throws a NumberFormatException this way, here's the stack trace: ' Exception in thread "main" java.lang. NumberFormatException: For input string: "string" at java.lang. NumberFormatException.

ForInputString(NumberFormatException. Java:48) at java.lang.Integer. ParseInt(Integer.

Java:449) at java.math.BigInteger.(BigInteger. Java:316) at java.math.BigInteger.(BigInteger. Java:451) at rsa.RSAEncryptor.

Encrypt(RSAEncryptor. Java:32) at rsa.Main. Main(Main.

Java:20) ' – Egor Apr 29 at 9:17.

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