houbb/sensitive

StrategyPhone对于带区号的号码无法脱敏

SilvesSun opened this issue · 1 comments

commonSensitiveTest

    @Test
    public void commonSensitiveTest() {
        final String originalStr = "User{username='脱敏君', idCard='123456190001011234', password='1234567', email='12345@qq.com', phone='86-18888888888'}";
        final String sensitiveStr = "User{username='脱**', idCard='123456**********34', password='null', email='12******.com', phone='86-1888****888'}";

        User user = DataPrepareTest.buildUser();
        Assert.assertEquals(originalStr, user.toString());

        User sensitiveUser = SensitiveUtil.desCopy(user);
        Assert.assertEquals(sensitiveStr, sensitiveUser.toString());
        Assert.assertEquals(originalStr, user.toString());
    }

这个竟然没收到提示。

默认实现只做了手机号部分的脱敏实现,一般也满足安全需求,如果有特别的需求可以自己实现。