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:

  1. User ID
  2. Chinese name
  3. ID card number
  4. Landline number
  5. Mobile number
  6. Address
  7. Email
  8. Password
  9. Chinese mainland license plate, including ordinary vehicles and new energy vehicles
  10. 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, and qiaomu, which looks like three people…