I have written a program in java for RSA algorithm to encrypt a string and decrypt on receiver side. RSA public key and n value are announced to receiver by sender. Then encryption process begins. The RSA program in sender side returns BigInteger which is the encrypted string and I converted it to byte array.And sent to the receiver through datagram socket.On the receiver side the byte array is converted into BigInteger and decryption is done.This is the logic behind the program and it worked well.
I just changed the program such that, instead of using datagram, i wrote the encrypted byte array in sender to a file as bytes.On the receiver side I read it from the file as bytes and done the decryption.Now the problem is decryption failed while attempting like this.
Please help me to solve this problem.Thanks in advance.