@Test public void testMaskByType() { assertThat(DataMask.mask("王守仁", SensitiveType.Name)).isEqualTo("**仁"); assertThat(DataMask.mask("13599090990", SensitiveType.Phone)).isEqualTo("135*****990"); assertThat(DataMask.mask("441421199902132221", SensitiveType.IDCard)).isEqualTo("44142***********21"); assertThat(DataMask.mask("441421199902132221", SensitiveType.BankCard)).isEqualTo("4414************21"); assertThat(DataMask.mask("广东省广州市荔湾区花地湾1号", SensitiveType.Address)).isEqualTo("广东省广州市荔湾区*****"); assertThat(DataMask.mask("test@vipshop.com", SensitiveType.Email)).isEqualTo("t**t@vipshop.com"); assertThat(DataMask.mask("9527", SensitiveType.Captcha)).isEqualTo("9**7"); assertThat(DataMask.mask("441421199902132221", SensitiveType.Passport)).isEqualTo("44**************21"); assertThat(DataMask.mask("9527", SensitiveType.Password)).isEqualTo("****"); assertThat(DataMask.mask("account", SensitiveType.Account)).isEqualTo("a*****t"); assertThat(DataMask.mask("default", SensitiveType.Default)).isEqualTo("d******"); assertThat(DataMask.mask("test", SensitiveType.Hash)).isEqualTo(new HashMask().mask("test", null)); }
public static String mask(String source) { try { return mask(source, SensitiveType.Default); } catch (Exception e) { return source; } }
DataMask { public static String mask(String source) { try { return mask(source, SensitiveType.Default); } catch (Exception e) { return source; } } }
DataMask { public static String mask(String source) { try { return mask(source, SensitiveType.Default); } catch (Exception e) { return source; } }  }
DataMask { public static String mask(String source) { try { return mask(source, SensitiveType.Default); } catch (Exception e) { return source; } }  static void setHashSalt(String salt); static String mask(String source); static String mask(String source, SensitiveType type); static String mask(String source,MaskStrategy strategy,int...param); static String toJSONString(Object object); static String toString(Object object); }
DataMask { public static String mask(String source) { try { return mask(source, SensitiveType.Default); } catch (Exception e) { return source; } }  static void setHashSalt(String salt); static String mask(String source); static String mask(String source, SensitiveType type); static String mask(String source,MaskStrategy strategy,int...param); static String toJSONString(Object object); static String toString(Object object);  }