小结

jdk配置sql打印

-Xms512m -Xmx2024m  -Dorg.jboss.logging.provider="slf4j"

 

数据脱敏

public static String toConceal(String value) {
	 int SIZE = 6;
     String SYMBOL = "*";
    if (null == value || "".equals(value)) {
        return value;
    }
    int len = value.length();
    int pamaone = len / 2;
    int pamatwo = pamaone - 1;
    int pamathree = len % 2;
    StringBuilder stringBuilder = new StringBuilder();
    if (len <= 2) {
        if (pamathree == 1) {
            return SYMBOL;
        }
        stringBuilder.append(value.charAt(0));
        stringBuilder.append(SYMBOL);
    } else {
        if (pamatwo <= 0) {
            stringBuilder.append(value.substring(0, 1));
            stringBuilder.append(SYMBOL);
            stringBuilder.append(value.substring(len - 1, len));

        } else if (pamatwo >= SIZE / 2 && SIZE + 1 != len) {
            int pamafive = (len - SIZE) / 2;
            stringBuilder.append(value.substring(0, pamafive));
            for (int i = 0; i < SIZE; i++) {
                stringBuilder.append(SYMBOL);
            }
            if ((pamathree == 0 && SIZE / 2 == 0) || (pamathree != 0 && SIZE % 2 != 0)) {
                stringBuilder.append(value.substring(len - pamafive, len));
            } else {
                stringBuilder.append(value.substring(len - (pamafive + 1), len));
            }
        } else {
            int pamafour = len - 2;
            stringBuilder.append(value.substring(0, 1));
            for (int i = 0; i < pamafour; i++) {
                stringBuilder.append(SYMBOL);
            }
            stringBuilder.append(value.substring(len - 1, len));
        }
    }
    return stringBuilder.toString();

}

 

阅读更多
换一批

没有更多推荐了,返回首页