hello...!
i'm trying to write a code for RSA encryption\decrytion... i found code from internet.. it works well with biginterger... but when i tried to convert decrypted(bignteger) into it give me different output.... following is a code.. please check this...

RSA Code

import java.math.BigInteger;
import java.security.SecureRandom;
public class Main {



public static final BigInteger one = new BigInteger("1");
public static final SecureRandom rs = new SecureRandom();

private BigInteger privateKey;
public BigInteger publicKey;
private BigInteger modulus;

public void RSAKey(int n){
BigInteger p = BigInteger.probablePrime(n/2, rs);
BigInteger q = BigInteger.probablePrime(n/2, rs);
BigInteger phi = (p.subtract(one)).multiply(q.subtract(one));

modulus = p.multiply(q);
publicKey = new BigInteger("65537");
privateKey = publicKey.modInverse(phi);


}

public BigInteger encrypt(BigInteger message){
return message.modPow(privateKey, modulus);
}

public BigInteger decrypt(BigInteger message){
return message.modPow(publicKey, modulus);
}



public static void main(String[] args) {
Main m = new Main();
m.RSAKey(10);
//String msg = "Hello";
char[] msg = {'h','e','l','l','o'};

String smsg = new String(msg);
System.out.println("Smsg"+smsg);
byte[] test = smsg.getBytes();
String test1 = new String(test);

System.out.println("smsg"+smsg);
System.out.println("test"+test);
System.out.println("test1"+test1);
BigInteger cc = new BigInteger(smsg);

BigInteger cipher = m.encrypt(cc);
BigInteger plain = m.decrypt(cipher);
String msgg = new String(plain.toByteArray());
System.out.println();
System.out.println();
System.out.println();

System.out.println("Message"+cc);
System.out.println("cipher"+cipher);
System.out.println("decrypt"+plain);
System.out.println("plantext"+msgg);


}

}