当前位置:网站首页>Additional: information desensitization;
Additional: information desensitization;
2022-07-02 02:12:00 【Small withered forest】
explain :
(1) Why did you write this blog ?:
● stay 【26: The third chapter : Developing a pass service :9】 in , We added AppUser Data time , When setting user nicknames , Write an information desensitization tool DesensitizationUtil Tool class ;( You can put 【 user +18888888888】 Turn into 【 user +18******888】 In the form of );
● This blog will introduce the information desensitization tool DesensitizationUtil;
(2) Actually , This blog is mainly to clarify two points :
● For the project , Some need to be displayed on the front desk , But at the same time, I don't want to divulge secrets , Consider information desensitization ;
● then , This blog , It's just a case of information desensitization ; For other projects , Although there is a need for information desensitization , But this demand is different ( For example, some require 18888888888 Turn into 18***888***; Some require 18888888888 Turn into 18######888; Some asked to turn Li Erzhu into Li * Column, etc )
(3) in the future , In other projects , Encounter specific information desensitization needs , Then according to the actual situation , Write specific 、 Just solve it with appropriate logic ;
Catalog
One : stay 【26: The third chapter : Developing a pass service :9】 in ,DesensitizationUtil Content of tool class ;
package com.imooc.utils; /** * General desensitization tool class * Can be used for : * user name * cell-phone number * mailbox * Address, etc */ public class DesensitizationUtil { private static final int SIZE = 6; private static final String SYMBOL = "*"; public static void main(String[] args) { String name = commonDisplay(" For class network "); String mobile = commonDisplay("13900000000"); String mail = commonDisplay("[email protected]"); String address = commonDisplay(" Beijing Grand Canal East Road 888 Number "); System.out.println(name); System.out.println(mobile); System.out.println(mail); System.out.println(address); } /** * General desensitization method * @param value * @return */ public static String commonDisplay(String value) { if (null == value || "".equals(value)) { return value; } int len = value.length(); int pamaone = len / 2; int pamatwo = pamaone - 1; int pamathree = len % 2; StringBuilder stringBuilder = new StringBuilder(); if (len <= 2) { if (pamathree == 1) { return SYMBOL; } stringBuilder.append(SYMBOL); stringBuilder.append(value.charAt(len - 1)); } else { if (pamatwo <= 0) { stringBuilder.append(value.substring(0, 1)); stringBuilder.append(SYMBOL); stringBuilder.append(value.substring(len - 1, len)); } else if (pamatwo >= SIZE / 2 && SIZE + 1 != len) { int pamafive = (len - SIZE) / 2; stringBuilder.append(value.substring(0, pamafive)); for (int i = 0; i < SIZE; i++) { stringBuilder.append(SYMBOL); } if ((pamathree == 0 && SIZE / 2 == 0) || (pamathree != 0 && SIZE % 2 != 0)) { stringBuilder.append(value.substring(len - pamafive, len)); } else { stringBuilder.append(value.substring(len - (pamafive + 1), len)); } } else { int pamafour = len - 2; stringBuilder.append(value.substring(0, 1)); for (int i = 0; i < pamafour; i++) { stringBuilder.append(SYMBOL); } stringBuilder.append(value.substring(len - 1, len)); } } return stringBuilder.toString(); } }explain :
(1) This code , I didn't look carefully ; But I glanced a little , The basic idea is : After considering all abnormal conditions , hold 18888888888 Turn into 18******888;
边栏推荐
猜你喜欢
![[question] - why is optical flow not good for static scenes](/img/8d/2cf6f582bc58cc2985f50e3f85f334.jpg)
[question] - why is optical flow not good for static scenes

What are the necessary things for students to start school? Ranking list of Bluetooth headsets with good sound quality

【视频】马尔可夫链原理可视化解释与R语言区制转换MRS实例|数据分享

An analysis of circuit for quick understanding

SQLite 3 of embedded database

The concepts and differences between MySQL stored procedures and stored functions, as well as how to create them, the role of delimiter, the viewing, modification, deletion of stored procedures and fu

跨域?同源?一次搞懂什么是跨域

Sword finger offer 62 The last remaining number in the circle

分卷压缩,解压

golang---锁
随机推荐
C language 3-7 daffodils (enhanced version)
剑指 Offer 29. 顺时针打印矩阵
【毕业季】研究生学长分享怎样让本科更有意义
1222. Password dropping (interval DP, bracket matching)
2022 Q2 - résumé des compétences pour améliorer les compétences
Comparative analysis of MVC, MVP and MVVM, source code analysis
How to batch add background and transition effects to videos?
There are spaces in the for loop variable in the shell -- IFS variable
Flutter un élément au milieu, l'élément le plus à droite
how to add one row in the dataframe?
如何用一款产品推动「品牌的惊险一跃」?
Five skills of adding audio codec to embedded system
SQL server calculates the daily average and annual average of the whole province
跨域?同源?一次搞懂什么是跨域
Post infiltration flow encryption
Infix expression to suffix expression (computer) code
如何远程、在线调试app?
Webgpu (I): basic concepts
Open那啥的搭建文档
Using mongodb in laravel
