Python implements data desensitization

background

The previous article talked about "One annotation to achieve data desensitization", which is actually quite convenient to use. He shigenis a person who likes to mess around. For the Python interface, how to achieve data desensitization? I have been looking for tutorials for a long time and found that there is not much information about this part, and most of them are handwritten desensitization algorithms. In the end, I compromised and used regular expressions to desensitize the data. In this article, we will flask+fakerimplement an interface and process it with regular expressions. It will return desensitized random data.

Code

  • Define a general regular expression matching tool

What is achieved is to turn data that conforms to the rules into desensitized data.

I have to say that it still tests your regular expression skills, but shigenthis one can still be used universally. It is recommended to use it.

  • faker simulates generated data

Here, faker is used to generate simulated data, and then passed into the corresponding method for further matching processing, and finally packaged into a json data and returned to the front end.

Try calling it, the data returned each time is different, and the data desensitization requirements are also implemented as scheduled:

Summarize

The above is the entire content of "Python Implements Data Desensitization". Friends who think it is a good book remember it 点赞 在看 关注 分享. Your encouragement is shigenthe driving force for continuous updates.

This is also an article that I am struggling with, and it took a long time to implement it, which caused my daily news to be published much later. It’s still my lack of preparation, and it’s also related to my preference for excellence.

Together shiegen, every day is different!

Guess you like

Origin blog.csdn.net/weixin_55768452/article/details/132844560