增加身份证脱敏
This commit is contained in:
parent
9cad965750
commit
a0ad6332d5
@ -65,4 +65,20 @@ public class IdCardUtil {
|
|||||||
return age;
|
return age;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 身份证脱敏
|
||||||
|
*
|
||||||
|
* @param idCard
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String removeSensitive(String idCard) {
|
||||||
|
if (!RegexUtil.isIdentity(idCard)) {
|
||||||
|
throw new ParamsException("身份证格式错误");
|
||||||
|
}
|
||||||
|
if (idCard.length() == 15) {
|
||||||
|
return idCard.replaceAll("(\\w{6})\\w*(\\w{3})", "$1******$2");
|
||||||
|
}
|
||||||
|
return idCard.replaceAll("(\\w{6})\\w*(\\w{3})", "$1*********$2");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user