package com.nuvole.util;
|
|
import cn.hutool.core.util.StrUtil;
|
|
/**
|
* @author ChenLong
|
* @version 1.0
|
* @ClassName DesensitizationUtil
|
* @date 2019/4/28 19:37
|
* @Description 脱敏工具类
|
*/
|
public class DesensitizationUtil {
|
|
public static String esensitizationdName(String str) {
|
if (StrUtil.isBlank(str)) {
|
return "";
|
}
|
String res = str.substring(0, 1);
|
for (int i = 1; i < str.length(); i++) {
|
res += "*";
|
}
|
return res;
|
}
|
|
/**
|
* Createed by PKZ
|
* Date 2019/6/4 13:35
|
* Description:手机号脱敏
|
**/
|
public static String esensitizationdMobile(String mobile) {
|
if (StrUtil.isBlank(mobile)) {
|
return "";
|
}
|
if (mobile.length() != 11) {
|
return "";
|
}
|
String start = mobile.substring(0, 3);
|
String end = mobile.substring(mobile.length() - 4, mobile.length());
|
return start + "****" + end;
|
}
|
|
/**
|
* Createed by PKZ
|
* Date 2019/6/4 13:35
|
* Description:身份证号脱敏
|
**/
|
public static String esensitizationdIdcard(String idcard) {
|
if (StrUtil.isBlank(idcard)) {
|
return "";
|
}
|
if (idcard.length() != 18) {
|
return "";
|
}
|
String start = idcard.substring(0, 4);
|
String end = idcard.substring(idcard.length() - 4, idcard.length());
|
return start + "******" + end;
|
}
|
}
|