duhuizhe
2024-04-17 c389984b5d3e5523e1b22de1fc045dc415261330
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package com.yqzx.common.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;
    }
}