中国算力平台算力登记系统2.0
yanzhaofeige
6 days ago 346e19ed91e10ac14722fcc29dbb810b9d971d3d
commit | author | age
43dc29 1 package com.odcc.cpzidc.common.utils;
Y 2
3 /**
4  * 脱敏工具类
5  *
6  * @author ruoyi
7  */
8 public class DesensitizedUtil
9 {
10     /**
11      * 密码的全部字符都用*代替,比如:******
12      *
13      * @param password 密码
14      * @return 脱敏后的密码
15      */
16     public static String password(String password)
17     {
18         if (StringUtils.isBlank(password))
19         {
20             return StringUtils.EMPTY;
21         }
22         return StringUtils.repeat('*', password.length());
23     }
24
25     /**
26      * 车牌中间用*代替,如果是错误的车牌,不处理
27      *
28      * @param carLicense 完整的车牌号
29      * @return 脱敏后的车牌
30      */
31     public static String carLicense(String carLicense)
32     {
33         if (StringUtils.isBlank(carLicense))
34         {
35             return StringUtils.EMPTY;
36         }
37         // 普通车牌
38         if (carLicense.length() == 7)
39         {
40             carLicense = StringUtils.hide(carLicense, 3, 6);
41         }
42         else if (carLicense.length() == 8)
43         {
44             // 新能源车牌
45             carLicense = StringUtils.hide(carLicense, 3, 7);
46         }
47         return carLicense;
48     }
49 }