G
Gandu
Could some Java guru please point out what I am doing wrong? I have
created a simple RSA class using java.math.BigInteger. In public
static void main(...) I
have:
RSA rsa = new RSA();
rsa.genKeys();
rsa.showKeys();
String str = new String("This is RSA test");
byte [] byteArray = str.getBytes();
BigInteger bigInt = new BigInteger(byteArray);
BigInteger result = rsa.decrypt(rsa.encrypt(bigInt));
if(result != null){
String str1 = new String(result.toByteArray());
System.out.println(str1);
}
The print statement prints a starnge looking String. However, if I use
BigInteger bigInt = new BigInteger("1234567890");
instead of BigInteger bigInt = new BigInteger(byteArray); in above,
the
output is 1234567890
Could someone please point out what I am doing wrong? Thanks in
advance for
your help.
created a simple RSA class using java.math.BigInteger. In public
static void main(...) I
have:
RSA rsa = new RSA();
rsa.genKeys();
rsa.showKeys();
String str = new String("This is RSA test");
byte [] byteArray = str.getBytes();
BigInteger bigInt = new BigInteger(byteArray);
BigInteger result = rsa.decrypt(rsa.encrypt(bigInt));
if(result != null){
String str1 = new String(result.toByteArray());
System.out.println(str1);
}
The print statement prints a starnge looking String. However, if I use
BigInteger bigInt = new BigInteger("1234567890");
instead of BigInteger bigInt = new BigInteger(byteArray); in above,
the
output is 1234567890
Could someone please point out what I am doing wrong? Thanks in
advance for
your help.