当前位置:网站首页>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;
边栏推荐
- STM32F103——两路PWM控制电机
- Five skills of adding audio codec to embedded system
- Sword finger offer 62 The last remaining number in the circle
- 2022 Q2 - Summary of skills to improve skills
- The middle element and the rightmost element of the shutter
- Construction and maintenance of business websites [12]
- JPM 2021 most popular paper released (with download)
- 【毕业季】研究生学长分享怎样让本科更有意义
- STM32F103 - two circuit PWM control motor
- Openssl3.0 learning XXI provider encoder
猜你喜欢
321. Chessboard segmentation (2D interval DP)
Opencascade7.6 compilation
leetcode373. Find and minimum k-pair numbers (medium)
Decipher the AI black technology behind sports: figure skating action recognition, multi-mode video classification and wonderful clip editing
MySQL constraints and multi table query example analysis
Redis有序集合如何使用
Data analysis on the disaster of Titanic
Software development life cycle -- waterfall model
leetcode2309. The best English letters with both upper and lower case (simple, weekly)
开发工具创新升级,鲲鹏推进计算产业“竹林”式生长
随机推荐
"C language programming", 4th Edition, edited by he Qinming and Yan Hui, after class exercise answers Chapter 3 branch structure
Automatically browse pinduoduo products
"C language programming", 4th Edition, edited by he Qinming and Yan Hui, after class exercise answers Chapter 3 branch structure Exercise 3
What is the MySQL column to row function
[技术发展-21]:网络与通信技术的应用与发展快速概览-1- 互联网网络技术
【C#】使用正则校验内容
An analysis of circuit for quick understanding
Design and implementation of key value storage engine based on LSM tree
How to solve MySQL master-slave delay problem
D discard the virtual recovery method
leetcode2310. The one digit number is the sum of integers of K (medium, weekly)
MySQL中一条SQL是怎么执行的
Types of exhibition items available in the multimedia interactive exhibition hall
[C #] use regular verification content
leetcode2305. Fair distribution of biscuits (medium, weekly, shaped pressure DP)
剑指 Offer 31. 栈的压入、弹出序列
Failed to transform file 'xxx' to match attributes
This is the report that leaders like! Learn dynamic visual charts, promotion and salary increase are indispensable
Spend a week painstakingly sorting out the interview questions and answers of high-frequency software testing / automated testing
Word search applet design report based on cloud development +ppt+ project source code + demonstration video