In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "Java how to use poi to complete Excel export data desensitization", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "Java how to use poi to complete Excel export data desensitization" bar!
The definition of desensitized Baidu encyclopedia: refers to the deformation of some sensitive information through desensitization rules to achieve the reliable protection of sensitive private data. In the case of customer security data or some commercially sensitive data, under the condition of not violating the system rules, transform the real data and provide testing use, such as ID number, mobile phone number, card number, customer number and other personal information need to be desensitized.
If this piece is in strict accordance with the definition to achieve the deformation of ID card and other data, the author has not yet implemented it, because the desensitization rules of this design correspond to the corresponding desensitization rules and require users to specify rules, and our internal desensitization system still has some logic. I won't talk about it in detail here. This time, the main implementation is to add the * sign [later plus custom bar, after all, the common are asterisks], it is convenient to hide non-essential fields when exporting data.
Maintain data
Main function
There are three main functions to be implemented:
1. Hidden ending, suitable for fixed length, such as mobile phone number, ID card
two。 Hidden part, not fixed length, such as name, address
3. To hide a specific part, especially to indicate a reservation, such as a mailbox.
The effect that is simply achieved is
13112345678-- > 131 million dollars 1234
Zhang San-> Zhang *
Ronaldinho-- > Ronaldo
Wuyun@163.com-> w****@16com.com
Desensitization effect
Implementation method 1. Notes
Annotations are also implemented through the @ Excel attribute. The desensitizationRule attribute is added to @ Excel, and the corresponding results can be obtained through the configuration of the desensitizationRule attribute.
/ * * data desensitization rule * Rule 1: keep the head and tail, with an asterisk on the intermediate data * for example, if the ID card is 6 "4, keep 370101" 1234 * the mobile phone number 3 "4 will retain 131"hidden" 1234 * Rule 2: hide by determining the hidden field. Priority retention head * such as: name 1jue 3 means the largest hidden 3, the smallest * Li-- > * * Li San-- > Li * * Zhang Quanyan-- > Zhang * Egg * Li Zhangquan-- > Li * * Egg * Nicholas. Li Zhangquan-> Nikolai * Zhang Quanyan * Rule 3: retain after special symbols * for example: email address 1: @ indicates that only the first bit and the fields after @ are retained * afterturn@wupaas.com-> a*@wupaas.com * complex version, please use API * {@ link cn.afterturn.easypoi.handler.inter.IExcelDataHandler} * / public String desensitizationRule () default ""
As you can see from the notes, the use of the three simple rules is relatively clear, mainly:
The first format that preserves the head and tail separated by an underscore
Both the beginning and end of the format can be 0, indicating that it is not reserved.
The second format of hidden portions of data separated by commas
The retention rule is dominated by symmetry.
Distinguished by the ~ sign and retaining the format after the special characters
If there are multiple special characters, only the data of the last bit is retained.
The specific implementation code is as follows:
/ * specific character separation, add an asterisk * @ param start * @ param mark * @ param value * @ return * / private static String markSpilt (int start, String mark, String value) {if (value = = null) {return null;} int end = value.lastIndexOf (mark) If (end end) {throw new IllegalArgumentException ("start must less end");} int len = value.length (); if (len start & & len
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.