Note that, while the modulus may be 1024 bits, the public key consists of at least the modulus and the exponent. In fact, it contains even more information, such as the fact the public key algorithm is RSA, and other descriptive information. On my computer, in the one instance I checked, this file was in fact 162 bytes in length. Never assume you know what the length is in advance. Either save the length somewhere (ky.length), or let the filesystem tell you the length. You should become familiar with the DataInputStream and DataOutputStream classes; they are very useful. For example, consider this alternative sequence of Java which produces the correct result:
I have not examined the rest of the code for errors.
Thank you Ulf and Greg. But these changes are not made any difference, i am getting same exception. I am searching google for references, but they are using MD5 to encode and checking signatures also. I am confused can't we simply read from txt files and recreate the RSA keys? is it is not that simpler? folks please help! [ September 21, 2008: Message edited by: Bala Raju Mandala ]