I use the following code to create BigIntegerfrom a hexadecimal string and printing for output.
package javaapplication2;
import java.math.BigInteger;
import javax.xml.bind.DatatypeConverter;
public class JavaApplication2 {
public static void main(String[] args) {
String HexString = "e04fd020ea3a6910a2d808002b30309d";
byte[] ByteArray = toByteArray(HexString);
BigInteger BigNumber = new BigInteger(ByteArray);
System.out.print(BigNumber + "\n");
}
public static String toHexString(byte[] array) {
return DatatypeConverter.printHexBinary(array);
}
public static byte[] toByteArray(String s) {
return DatatypeConverter.parseHexBinary(s);
}
}
After this code I get the following result:
-42120883064304190395265794005525319523
But I expect to see this result:
298161483856634273068108813426242891933
What am I doing wrong?
source
share