Commit b898f4abaa0125729060bd84b8b0fd60c76b7794

Authored by hujiaqi
1 parent e7a88a0c4a
Exists in master

修改风险因素

Showing 1 changed file with 21 additions and 0 deletions

platform-common/src/main/java/com/lyms/platform/common/utils/DefenceUtils.java View file @ b898f4a
... ... @@ -40,5 +40,26 @@
40 40 return "";
41 41 }
42 42  
  43 + /**
  44 + * @auther HuJiaqi
  45 + * @createTime 2016年12月26日 14时28分
  46 + * @discription 加密cardNo,手机号和身份证号按照以上规则,其余明文返回
  47 + */
  48 + public static String getCardNo(String cardNo) {
  49 + if (org.apache.commons.lang.StringUtils.isEmpty(cardNo)) {
  50 + return "";
  51 + }
  52 + if (cardNo.length() == 15) {
  53 + return cardNo.substring(0, 6) + "****" + cardNo.substring(10, 13) + "*" + cardNo.substring(14);
  54 + }
  55 + if (cardNo.length() == 18) {
  56 + return cardNo.substring(0, 6) + "******" + cardNo.substring(12, 15) + "**" + cardNo.substring(17);
  57 + }
  58 + if (cardNo.length() == 11) {
  59 + return cardNo.substring(0, 3) + "****" + cardNo.substring(7);
  60 + }
  61 + return cardNo;
  62 + }
  63 +
43 64 }