[update] 数据处理:去隐私配置 去除十六进制散列修改
This commit is contained in:
parent
4d90274564
commit
8fe4183adf
@ -538,8 +538,10 @@ public class DataProcessUtil {
|
||||
*/
|
||||
private static final String CREDIT_CARD_REGEX = "^([1-9]{1})(\\d{15}|\\d{18})$";
|
||||
|
||||
// 定义一个正则表达式来匹配常见的十六进制散列格式(32位十六进制数,用于SHA-256等)
|
||||
private static final String HASH_REGEX = "\\b[a-fA-F0-9]{32}\\b";
|
||||
/**
|
||||
* 十六进制散列的正则表达式(32或24 位十六进制数,用于 SHA-256 等)
|
||||
*/
|
||||
private static final String HASH_REGEX = "[a-fA-F0-9]{32}|[a-fA-F0-9]{24}";
|
||||
|
||||
// 编译正则表达式为Pattern对象
|
||||
private static final Pattern MOBILE_PATTERN = Pattern.compile(MOBILE_REGEX);
|
||||
@ -576,8 +578,7 @@ public class DataProcessUtil {
|
||||
text = removeCreditCard(text);
|
||||
|
||||
// 使用正则表达式匹配十六进制散列
|
||||
Matcher hashMatcher = HASH_PATTERN.matcher(text);
|
||||
text = hashMatcher.replaceAll("");
|
||||
text = removeHashMatcher(text);
|
||||
|
||||
// // 使用StringBuilder和StringBuilder的replace方法去除其他数字,但跳过年份和简单数字
|
||||
// // TODO: 这里目前有bug,先注释掉了。
|
||||
@ -592,6 +593,7 @@ public class DataProcessUtil {
|
||||
return text;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 去除电话号码
|
||||
*
|
||||
@ -622,6 +624,18 @@ public class DataProcessUtil {
|
||||
return text;
|
||||
}
|
||||
|
||||
/**
|
||||
* 去除十六进制散列
|
||||
*
|
||||
* @param text 文本
|
||||
* @return 去除十六进制散列后的文本
|
||||
*/
|
||||
private static String removeHashMatcher (String text) {
|
||||
Matcher hashMatcher = HASH_PATTERN.matcher(text);
|
||||
text = hashMatcher.replaceAll("");
|
||||
return text;
|
||||
}
|
||||
|
||||
// 查找下一个要替换的数字的起始索引
|
||||
private static int findNextNumberToReplace (String text) {
|
||||
// 这里可以添加更复杂的逻辑来定位要替换的数字,但为了简化,我们假设数字以空格或非数字字符分隔
|
||||
|
Loading…
x
Reference in New Issue
Block a user