### Question:
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);  }### Answer:
@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)); }
@Test public void testMask() { assertThat(DataMask.mask("test")).isEqualTo("t***"); }
@Test public void testSha1Mask() throws Exception { String hash = DataMask.mask("test", SensitiveType.Hash); System.out.println(hash); String salt = HashMask.getSalt(); String encrypt =EncodeUtil.encodeHex(HashUtil.sha1("test"+salt)); assertThat(hash).isNotNull().isEqualTo(encrypt); }