提交 | 用户 | 时间
|
a6316e
|
1 |
package com.billion.common.utils; |
A |
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 |
} |