Question

I am trying to convert a hex string to a decimal value (integer). Having found

int i = Integer.valueOf(s, 16).intValue();

here,

i achieved to convert a hex string up to a certain size to an int.

But when the string gets larger, then the int or long does not work, so i tried BigInteger.

Unfortunately, it returns an error :

JEncrytion.java:186: <identifier> expected
                        BigInteger part_user_hex = Integer.valueOf("45ffaaaaa", 16).int();


JEncrytion.java:186: illegal start of expression
                        BigInteger part_user_hex = Integer.valueOf("45ffaaaaa", 16).int();


JEncrytion.java:186: not a statement
                        BigInteger part_user_hex = Integer.valueOf("45ffaaaaa", 16).int();

The code fragment is :

String[] parts = final_key.split("@") ;

String part_fixed = parts[0]; 

String part_user = parts[1]; 

BigInteger part_user_hex = Integer.valueOf("45ffaaaaa", 16).int();

System.out.println(""); 

System.out.println("hex value of the key : " + part_user_hex);  

Any ideas what to do?

3 errors

Was it helpful?

Solution

You're trying to assign a primitive int value to a BigInteger reference variable. That won't work. You want to do

BigInteger hex = new BigInteger("45ffaaaaa", 16);

Also, you've named your class JEncrytion instead of JEncryption.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top