当前位置:网站首页>Desensitize data

Desensitize data

2022-07-23 13:10:00 Withered maple leaf

Data desensitization tool
First step : First introduced hutool Tool coordinates

<dependency>
            <groupId>cn.hutool</groupId>
            <artifactId>hutool-all</artifactId>
            <version>4.5.0</version>
        </dependency>

The second step : Desensitization with tools

if (!CollectionUtils.isEmpty(winningVOList)) {
    
            for (WinningVO winningVO : winningVOList) {
    
                //  name 
                String userName = winningVO.getName();
                winningVO.setName(StringUtils.isEmpty(userName) ? "" : ((userName.length() > 2) ? StrUtil.hide(userName, 1, userName.length() - 1) : StrUtil.hide(userName, 1, userName.length())));

                //  ID number 
                String licenseNumber = winningVO.getIdCard();
                winningVO.setIdCard(StringUtils.isEmpty(licenseNumber) ? "" : StrUtil.hide(licenseNumber, 3, 14));

                //  cell-phone number 
                String userPhone = winningVO.getPhone();
                winningVO.setPhone(StringUtils.isEmpty(userPhone) ? "" : StrUtil.hide(userPhone, 3, 7));
            }
        }
原网站

版权声明
本文为[Withered maple leaf]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/204/202207230540586001.html