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

Example code of layim integrating right-click menu in JavaScript

Table of contents 1. Effect Demonstration 2. Impl...

Introduction and examples of hidden fields in HTML

Basic syntax: <input type="hidden" na...

React Synthetic Events Explained

Table of contents Start by clicking the input box...

Why the disk space is not released after deleting data in MySQL

Table of contents Problem Description Solution Pr...

A brief discussion on the definition and precautions of H tags

Judging from the results, there is no fixed patte...

Mysql implements three functions for field splicing

When exporting data to operations, it is inevitab...

Example analysis of mysql non-primary key self-increment usage

This article uses an example to illustrate the us...

Mini Program to Implement Paging Effect

This article example shares the specific code for...

Docker practice: Python application containerization

1. Introduction Containers use a sandbox mechanis...

How to install and deploy zabbix 5.0 for nginx

Table of contents Experimental environment Instal...

WeChat applet development form validation WxValidate usage

I personally feel that the development framework ...

Do designers need to learn to code?

Often, after a web design is completed, the desig...

How to dynamically add ports to Docker without rebuilding the image

Sometimes you may need to modify or add exposed p...

Complete step record of Vue encapsulation of general table components

Table of contents Preface Why do we need to encap...