public static boolean isBase64(String str) {
if (Utils.isEmptyTrim(str)) {
return false;
}
String base64Pattern = "^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)$";
boolean matches = Pattern.matches(base64Pattern, str);
if (matches) {
String decodeBase64Str = Base64Utils.decodeBase64Str(str);
String encodeBase64Str = Base64Utils.encodeBase64Str(decodeBase64Str);
if (str.equals(encodeBase64Str)) {
return true;
}
}
return false;
}
判断一个字符串是否被base64加密过
最新推荐文章于 2024-08-16 10:22:02 发布