手机号码和身份证前三后四脱敏


public static String mobileEncrypt(String mobile){
if(TextUtils.isEmpty(mobile) || (mobile.length() != 11)){
return mobile;
}
return mobile.replaceAll("(\\d{3})\\d{4}(\\d{4})","$1****$2");
}

public static String idEncrypt(String id){
if(TextUtils.isEmpty(id) || (id.length() < 8)){
return id;
}
return id.replaceAll("(?<=\\w{3})\\w(?=\\w{4})", "*");
}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM