Implementation of MYSQL (telephone number, ID card) data desensitization

Implementation of MYSQL (telephone number, ID card) data desensitization

1. Data desensitization explanation

In daily development needs, data desensitization is often encountered. For example, ID card numbers and mobile phone numbers need to be partially replaced with *. This can protect sensitive privacy information to a certain extent. So what is data desensitization?

In cases involving customer security data or some commercially sensitive data, real data will be modified and provided for testing without violating system rules. For example, personal information such as ID number, mobile phone number, card number, customer number, etc. need to be desensitized.

2. Data Desensitization Implementation

Data desensitization can be implemented by processing when searching for data in the database, or by processing after the data is found. The MySQL database query processing is documented here, which is implemented using mysql string functions.

3. SQL data desensitization implementation

CONCAT(), LEFT() and RIGHT() string functions are used in combination. Please see the specific implementation below.

CONCAT(str1,str2,…): Returns the string generated by the concatenation parameters
LEFT(str,len): Returns the len leftmost characters starting from the string str
RIGHT(str,len): Starting from the string str, return the rightmost len ​​characters

Phone number desensitization sql:

SELECT mobilePhone AS phone number before desensitization,CONCAT(LEFT(mobilePhone,3), '********' ) AS phone number after desensitization FROM t_s_user


ID card number desensitization sql:
SELECT idcard AS Unencrypted ID card, CONCAT(LEFT(idcard,3), '****' ,RIGHT(idcard,4)) AS Deencrypted ID card number FROM t_s_user


Reference: https://blog.csdn.net/eagle89/article/details/80309608

This is the end of this article about the implementation of MYSQL (telephone number, ID card) data desensitization. For more relevant MYSQL data desensitization content, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • A brief introduction to Java log desensitization framework sensitive
  • Detailed explanation of the code of Oracle custom desensitization function
  • Implementation method of data desensitization of java logs

<<:  Docker-compose image release process analysis of springboot project

>>:  Detailed explanation of the new background properties in CSS3

Recommend

Two ways to correctly clean up mysql binlog logs

mysql correctly cleans up binlog logs Preface: Th...

Summary of mysqladmin daily management commands under MySQL (must read)

The usage format of the mysqladmin tool is: mysql...

Summary of several replication methods for MySQL master-slave replication

Asynchronous replication MySQL replication is asy...

How to handle long data when displaying it in html

When displaying long data in HTML, you can cut off...

Float and Clear Float in Overview Page

1. Float: The main purpose is to achieve the effe...

Detailed explanation of the payment function code of the Vue project

1. Alipay method: Alipay method: Click Alipay to ...

HTML background color gradient effect achieved through CSS style

Effect screenshots: Implementation code: Copy code...

Use and understanding of MySQL triggers

Table of contents 1. What is a trigger? 2. Create...

The images in HTML are directly replaced by base64 encoded strings

Recently, I came across a webpage that had images ...

How to deploy nodejs service using Dockerfile

Initialize Dockerfile Assuming our project is nam...

Detailed explanation of the usage of scoped slots in Vue.js slots

Table of contents No slots Vue2.x Slots With slot...

W3C Tutorial (2): W3C Programs

The W3C standardization process is divided into 7...

Implementation of built-in modules and custom modules in Node.js

1. Commonjs Commonjs is a custom module in nodejs...

Detailed explanation of the use of state in React's three major attributes

Table of contents Class Component Functional Comp...

MySQL 5.7.23 installation and configuration graphic tutorial

This article records the detailed installation pr...