Commit a9f7481156f8dd3033f31460b3ae60ebe5de700b
1 parent
5984e41c89
Exists in
master
and in
7 other branches
新增证件号加密方法
Showing 1 changed file with 42 additions and 0 deletions
platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/FunvCommonUtil.java
View file @
a9f7481
... | ... | @@ -23,6 +23,28 @@ |
23 | 23 | public static String NO = "否"; |
24 | 24 | |
25 | 25 | /** |
26 | + * 证件号加密处理 | |
27 | + * @param id | |
28 | + * @return | |
29 | + */ | |
30 | + public static String getId(String id) { | |
31 | + if (org.apache.commons.lang.StringUtils.isEmpty(id)) { | |
32 | + return ""; | |
33 | + } | |
34 | + if (id.length() == 11) { | |
35 | + return id.substring(0, 3) + "****" + id.substring(7); | |
36 | + } | |
37 | + if (id.length() == 15) { | |
38 | + return id.substring(0, 6) + "****" + id.substring(10, 13) + "*" + id.substring(14); | |
39 | + } | |
40 | + if (id.length() == 18) { | |
41 | + return id.substring(0, 6) + "******" + id.substring(12, 15) + "**" + id.substring(17); | |
42 | + } | |
43 | + return ""; | |
44 | + } | |
45 | + | |
46 | + | |
47 | + /** | |
26 | 48 | * 返回中间四位数为*号的手机号 |
27 | 49 | * @param phone |
28 | 50 | * @return |
... | ... | @@ -242,6 +264,26 @@ |
242 | 264 | return sb.toString(); |
243 | 265 | } |
244 | 266 | |
267 | + public static final String YIN = "yin"; | |
268 | + public static final String YANG = "yang"; | |
269 | + public static final String JIA = "+"; | |
270 | + public static final String JIAN = "-"; | |
271 | + | |
272 | + /** | |
273 | + * | |
274 | + * @param s | |
275 | + * @return | |
276 | + */ | |
277 | + public static String checkYiGan(String s) { | |
278 | + if (StringUtils.isNotEmpty(s)){ | |
279 | + if (s.equals(YIN)){ | |
280 | + return JIAN; | |
281 | + }else if (s.equals(YANG)){ | |
282 | + return JIA; | |
283 | + } | |
284 | + } | |
285 | + return null; | |
286 | + } | |
245 | 287 | |
246 | 288 | |
247 | 289 |