敏感信息脱敏类
public String middleDesensitization(String information,int head,int tail){
if (StringUtils.isBlank(information)) {
return null;
}
return information.replaceAll("(?<=\\w{"+head+"})\\w(?=\\w{"+tail+"})", "*");
}
public String mailboxDesensitization(String information,int head){
if (StringUtils.isBlank(information)) {
return null;
}
return information.replaceAll("(^\\w{"+head+"})[^@]*(@.*$)", "$1****$2");
}
public String chineseDesensitization(String information,int head) {
if (StringUtils.isBlank(information)) {
return null;
}
int length = StringUtils.length(information);
return StringUtils.rightPad(StringUtils.left(information, length - head), length, "*");
}