Enum Class DesensitizeType
- All Implemented Interfaces:
Serializable, Comparable<DesensitizeType>, Constable
脱敏类型枚举
定义各种数据脱敏规则
使用示例:
@Desensitize(type = DesensitizeType.MOBILE) private String mobile; // 138****1234 @Desensitize(type = DesensitizeType.ID_CARD) private String idCard; // 110**********123
- Author:
- Kerbores(kerbores@riemann.tech)
-
Nested Class Summary
Nested classes/interfaces inherited from class Enum
Enum.EnumDesc<E> -
Enum Constant Summary
Enum Constants -
Method Summary
Modifier and TypeMethodDescriptiondesensitize(String value) 脱敏方法static DesensitizeTypeReturns the enum constant of this class with the specified name.static DesensitizeType[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
MOBILE
手机号脱敏规则:保留前3位和后4位,中间用****替换
示例:138****1234
-
ID_CARD
身份证号脱敏规则:保留前3位和后4位,中间按实际长度用*替换(长度保持,不泄露位数结构)
示例:110***********1234
-
EMAIL
邮箱脱敏规则:保留首字母和@后面的域名,中间用***替换
示例:k***@example.com;a@x.com → a***@x.com(单字符用户名也脱敏,原实现原样返回泄露)
-
BANK_CARD
银行卡号脱敏规则:保留前4位和后4位,中间按实际长度用*替换(长度保持,不泄露位数结构)
示例:6222********1234
-
ADDRESS
地址脱敏规则:保留前6个字符或一半长度(取较小值),后面用****替换
示例:北京市朝阳区****
-
NAME
姓名脱敏规则:保留首字符,后面用*替换
示例:张*、李**
-
PASSWORD
密码脱敏规则:全部替换为******
示例:******
-
CUSTOM
自定义脱敏规则:通过@Desensitize注解的prefixKeep、suffixKeep、replacer参数自定义
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
desensitize
-