为了保护客户隐私时常会用到脱敏等操作,下面就介绍几种数据脱敏的方式
JAVA
public static void main(String[] args) {
String phone = "18888888888";
String phoneNumber = phone.substring(0, 3) + "****" + phone.substring(7, phone.length());
System.out.println("phone总长度:" + phone.length());
System.out.println("phone前3位:" + phone.substring(0, 3));
System.out.println("phone中4位:" + phone.substring(3, 7));
System.out.println("phone后4位:" + phone.substring(7, phone.length()));
System.out.println("phone中4*:" + phoneNumber);
}
SQL
SELECT
INSERT ( 18888888888, 4, 4, '****' ) AS phone ,
INSERT ( '37292219960101555X', 5, 10, '****' ) AS ID
FROM
DUAL;