方式1,使用Integer

Integer.parseInt(str, 16)

如:

int baiduId = Integer.parseInt(tBaiduQid, 16);

方式2, 使用Long

Long.parseLong(tBaiduQid, 16)

如:

long baiduId = Long.parseLong(tBaiduQid, 16);

如果16进制数过大, 转10进制会报错, 则需要使用BigInteger来解决.

Exception in thread "main" java.lang.NumberFormatException: For input string: "9b328cf65ab40260"
	at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
	at java.lang.Integer.parseInt(Integer.java:583)
	at com.baidu.anti.ShoubaiHack.evaluate(ShoubaiHack.java:140)
	at com.baidu.anti.ShoubaiHack.main(ShoubaiHack.java:26)

方式3, 使用BigInteger

import java.math.BigInteger;
BigInteger bigInteger = new BigInteger(tBaiduQid, 16);
Logo

技术共进,成长同行——讯飞AI开发者社区

更多推荐