Q:

How to convert value greater than 1000 to char in java

I'm developing my own RSA implementation in java. and while encrypting the data I'm encrypting each letter one by one and after calculating m^e mod n I'm getting values greater than 1000 and if i try to convert that value with (char) 1034 I'm getting ? this symbol for each character and I'm not able to decrypt the cipher text back to plain text what can i do please suggest some idea ???   

A:

Don't cast to char. You need to encode your value. One possible simple encoding is hexadecimal. Radix-64 (or base64) are frequently used (as in OpenPGP). Another possible choice is base85.

