DesensitizedUtil
Introduction
In data processing or cleansing, it may involve de-sensitizing a lot of private information, so Hutool provides some de-sensitization methods for commonly used information.
Currently, the supported types of de-sensitized data include:
- User ID
- Chinese name
- ID card number
- Landline number
- Mobile number
- Address
- Password
- Chinese mainland license plate, including ordinary vehicles and new energy vehicles
- Bank card
In general, de-sensitization refers to hiding a portion of critical information in the information and replacing it with *
. Custom hiding can be completed using the StrUtil.hide
method.
Usage
Let’s take ID card numbers as an example:
// DesensitizedUtil.idCardNum("51343620000320711X", 1, 2);
For conventionally de-sensitized data, we don’t need to specify the number of hidden digits, such as mobile numbers:
// DesensitizedUtil.mobilePhone("18049531999");
There are also some simple and rough de-sensitizations, such as passwords, which only retain digit information:
// DesensitizedUtil.password("1234567890");
Acknowledgements This utility class was contributed by
dazer
,neusoft
, andqiaomu
, which looks like three people…