当前位置:网站首页>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;
边栏推荐
- A quick understanding of digital electricity
- 2022 Q2 - Summary of skills to improve skills
- C language 3-7 daffodils (enhanced version)
- Software development life cycle -- waterfall model
- The smart Park "ZhongGuanCun No.1" subverts your understanding of the park
- 正则表达式学习笔记
- 734. Energy stone (greed, backpack)
- How to turn off debug information in rtl8189fs
- What is the MySQL column to row function
- 软件开发生命周期 --瀑布模型
猜你喜欢

Webgpu (I): basic concepts
![[technology development -21]: rapid overview of the application and development of network and communication technology -1- Internet Network Technology](/img/2d/299fa5c76416f74bd1a693c433dd09.png)
[technology development -21]: rapid overview of the application and development of network and communication technology -1- Internet Network Technology

734. Energy stone (greed, backpack)

What is AQS and its principle

No programming code technology! Four step easy flower store applet

With the innovation and upgrading of development tools, Kunpeng promotes the "bamboo forest" growth of the computing industry

Opencascade7.6 compilation

MySQL约束与多表查询实例分析

附加:信息脱敏;

How to use redis ordered collection
随机推荐
[graduation season] graduate seniors share how to make undergraduate more meaningful
Comparative analysis of MVC, MVP and MVVM, source code analysis
The smart Park "ZhongGuanCun No.1" subverts your understanding of the park
CSDN article underlined, font color changed, picture centered, 1 second to understand
leetcode373. Find and minimum k-pair numbers (medium)
Types of exhibition items available in the multimedia interactive exhibition hall
[Video] visual interpretation of Markov chain principle and Mrs example of R language region conversion | data sharing
Redis环境搭建和使用的方法
How to batch add background and transition effects to videos?
Construction and maintenance of business websites [12]
如何远程、在线调试app?
pytest 测试框架
An analysis of circuit for quick understanding
AR增强现实可应用的场景
2022 Q2 - résumé des compétences pour améliorer les compétences
If you want to rewind the video picture, what simple methods can you use?
Construction and maintenance of business websites [10]
How to build and use redis environment
正则表达式学习笔记
自动浏览拼多多商品