In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
Today, I will talk to you about how to use regular expressions to intercept ID card numbers and encrypt them. Many people may not know much about it. In order to make you understand better, the editor summed up the following for you. I hope you can get something from this article.
1. The structure of the number
The citizenship number is a feature combination code, which is composed of a 17-digit ontology code and an one-digit check code. The order from left to right is: six-digit address code, eight-digit birthday code, three-digit sequence code and one-digit check code.
2. Address code (first six digits)
The administrative division code of the county (city, flag, district) where the permanent residence of the coding object is located shall be carried out in accordance with the provisions of gb/T2260.
3. Date of birth code (7th to 14th)
Indicates the year, month and day of the birth of the coding object, which is carried out in accordance with the provisions of gb/T7408, and there is no delimiter between the code of year, month and day.
4. Sequence code (15th to 17th digits)
Indicates that within the area identified by the same address code, the odd number of the sequence code is assigned to men and even numbers to women in the same year, month and day.
5. Check code (eighteenth digit)
As the check code of the tail number, it is calculated by the number compilation unit according to the unified formula. If someone's tail number is 0mer9, there will be no X, but if the tail number is 10, then it must be replaced by X, because if 10 is used as the tail number, then the person's ID card becomes 19 digits. X is the Roman numeral 10, using X instead of 10, can ensure that citizens' identity cards meet national standards.
After knowing the meaning of the various parts of the ID card number structure, we began to move on to the topic:
1. Define the object of a national region
Var aCity= {11: "Beijing", 12: "Tianjin", 13: "Hebei", 14: "Shanxi", 15: "Inner Mongolia", 21: "Liaoning", 22: "Jilin", 23: "Heilongjiang", 31: "Shanghai", 32: "Jiangsu", 33: "Zhejiang", 34: "Anhui", 35: "Fujian", 36: "Jiangxi", 37: "Shandong", 41: "Henan", 42: "Hubei", 43: "Hunan 44: Guangdong, 45: Guangxi, 46: Hainan, 50: Chongqing, 51: Sichuan, 52: Guizhou, 53: Yunnan, 54: Xizang, 61: Shaanxi, 62: Gansu, 63: Qinghai, 64: Ningxia, 65: Xinjiang, 71: Taiwan, 81: Hong Kong, 82: Macao, 91: abroad}
2. Regular expression judgment
Function isCardID (sId) {var iSum=0; var info= ""; if (! / ^\ d {17} (\ d | x) $/ i.test (sId)) return "the length or format of your ID card you entered is incorrect"; sId=sId.replace (/ x ID ID I, "a"); if (aCit [parseInt (sId.substr (0Magne2))] = = null) return "your ID card area is illegal" SBirthday=sId.substr (6Magazine 4) + "-" + Number (sId.substr (10Magne2)) + "-" + Number (sId.substr (12Power2)); var d=new Date (sBirthday.replace (/-/ g, "/")); if (d.getFullYear () + "-" + (d.getMonth () + 1) + "-" + d.getDate ()) return "illegal date of birth on ID card"; for (var I = 17otheri > = 0) I -) iSum + = (Math.pow (2))% 11) * parseInt (sId.charAt (17-I), 11); if (iSummer1) return "the ID number you entered is illegal"; / / aCity [parseInt (sId.substr (0))] + "," + sBirthday+ "," + (sId.substr (16))% 2? " Male: female); / / you can also determine the gender of the entered ID number return true;} after reading the above, do you have any further understanding of how to use regular expressions to intercept ID numbers and encrypt them? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.