mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
support x,y for sm2
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package cn.hutool.core.util;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.math.BigInteger;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
/**
|
||||
@@ -198,6 +199,7 @@ public class HexUtil {
|
||||
if (StrUtil.isEmpty(hexStr)) {
|
||||
return null;
|
||||
}
|
||||
hexStr = StrUtil.removeAll(hexStr, ' ');
|
||||
return decodeHex(hexStr.toCharArray());
|
||||
}
|
||||
|
||||
@@ -338,6 +340,19 @@ public class HexUtil {
|
||||
builder.append(toDigits[low]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hex(16进制)字符串转为BigInteger
|
||||
* @param hexStr Hex(16进制字符串)
|
||||
* @return {@link BigInteger}
|
||||
* @since 5.2.0
|
||||
*/
|
||||
public static BigInteger toBigInteger(String hexStr){
|
||||
if(null == hexStr){
|
||||
return null;
|
||||
}
|
||||
return new BigInteger(hexStr, 16);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------- Private method start
|
||||
|
||||
/**
|
||||
|
@@ -38,4 +38,11 @@ public class HexUtilTest {
|
||||
boolean isHex = HexUtil.isHexNumber(a);
|
||||
Assert.assertTrue(isHex);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void decodeTest(){
|
||||
String str = "e8c670380cb220095268f40221fc748fa6ac39d6e930e63c30da68bad97f885d";
|
||||
Assert.assertArrayEquals(HexUtil.decodeHex(str),
|
||||
HexUtil.decodeHex(str.toUpperCase()));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user