2 changed files with 34 additions and 2 deletions
@ -0,0 +1,27 @@
|
||||
package com.biutag.outeradmin.util; |
||||
|
||||
import com.biutag.util.StringUtils; |
||||
|
||||
/** |
||||
* 身份证以及手机号脱敏处理工具类 |
||||
*/ |
||||
public class DesensitizedUtil { |
||||
public static String encryptIDCard(String idCard) { |
||||
if (StringUtils.isNotBlank(idCard)) { |
||||
if (idCard.length() == 15) { |
||||
idCard = idCard.replaceAll("(\\w{6})\\w*(\\w{4})", "$1******$2"); |
||||
} |
||||
if (idCard.length() == 18) { |
||||
idCard = idCard.replaceAll("(\\w{6})\\w*(\\w{4})", "$1*********$2"); |
||||
} |
||||
} |
||||
return idCard; |
||||
} |
||||
|
||||
public static String encryptPhone(String phone) { |
||||
if (StringUtils.isNotBlank(phone)) { |
||||
phone = phone.replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2"); |
||||
} |
||||
return phone; |
||||
} |
||||
} |
||||
Loading…
Reference in new issue