mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
add base64 check
This commit is contained in:
@@ -540,7 +540,12 @@ public class SecureUtil {
|
||||
// issue#I90M9D
|
||||
// 某些特殊字符串会无法区分Hex还是Base64,此处使用系统属性强制关闭Hex解析
|
||||
final boolean decodeHex = SystemUtil.getBoolean(HUTOOL_CRYPTO_DECODE_HEX, true);
|
||||
return (decodeHex && Validator.isHex(key)) ? Hex.decode(key) : Base64.decode(key);
|
||||
if(decodeHex && Validator.isHex(key)){
|
||||
return Hex.decode(key);
|
||||
}else if(Base64.isTypeBase64(key)){
|
||||
return Base64.decode(key);
|
||||
}
|
||||
throw new IllegalArgumentException("Value is not hex or base64!");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -149,7 +149,8 @@ public class AESTest {
|
||||
|
||||
@Test
|
||||
void issue3766Test() {
|
||||
Assertions.assertThrows(CryptoException.class, ()->
|
||||
Assertions.assertThrows(IllegalArgumentException.class, ()->
|
||||
// data必须为hex或base64
|
||||
SecureUtil.aes("8888888888888888".getBytes()).decryptStr("哈哈"));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user