18BitID card standards in the State Bureau of Quality and Technical Supervision July 1, 1999 The implementation of the GB11643-1999 "citizenship number" has made a clear provision. GB11643-1999 citizenship numberIsGB11643-1989 Social Security number, which indicates that the original standard name "social security number" RenamedIs"Citizenship number", in addition, GB11643-1999 "citizenship number" from the date of implementation of the replacement of GB11643-1989. GB11643-1999 "citizenship number" main content is as follows:
I. Scope
This Standard specifies the encoding object, number structure, and representation of the citizenship number, so that each encoding object can obtain a unique, unchanged legal number.
Ii. Encoding object
The encoding object of the citizenship number isYesCitizens of the People's Republic of China.
3. Number structure and representation
1. Number Structure
A citizenship number is a combination of features and consists of a 17-digit ontology code and a verification code. Sort order from left to rightIs: Six-digit address code, eight-digit birth date code, three-digit sequence code, and one-digit verification code.
2. Address Code
Indicates the Administrative Code of the county (city, flag, district) where the resident account of the encoding object is located, which is executed according to GB/t2260.
3. Date of birth
Indicates the year, month, and day when the encoding object is born. The code is executed according to GB/t7408, and there is no separator between the year, month, and day codes.
4. Sequence Code
Indicates the sequence number of the person born on the same year, the same month, and the same day within the region specified by the same address code. The odd number of the sequence code is allocated to men, and the even number is allocated to women.
5. Verification Code
(1) 17-digit ontology weighted sum formula
S = sum (ai * WI), I = 0,..., 16, first sum the right of the first 17 digits
AI: indicatesID card numberCode numeric value
Wi: indicates the weighting factor at position I.
Wi: 7 9 10 5 8 4 2 1 6 3 7 9 10 5 8 4 2
(2) Computing Model
Y = Mod (S, 11)
(3) obtain the corresponding verification code through the modulo
Y: 0 1 2 3 4 5 6 7 8 9 10
Verification Code: 1 0x9 8 7 6 5 4 3 2
4. Example:
Chaoyang District, Beijing: 11010519491231002x
Shantou City, Guangdong Province: 440524188001010014
The following is the program code:
Private string checkcidinfo (string CID)
{
String [] acity = new string [] {null, "Beijing ", "Tianjin", "Hebei", "Shanxi", "Inner Mongolia", null, "Liaoning", "Jilin", "Black Dragon River ", null, null, "Shanghai", "Jiangsu", "Zhejiang", "Anwei", "Fujian", "Jiangxi ", "Shandong", null, "Henan", "Hubei", "Hunan", "Guangdong", "Guangxi", "Hainan", null, null, null, "Chongqing", "Sichuan", "Guizhou", "Yunnan", "Tibet", null, "Shaanxi ", "Gansu", "Qinghai", "Ningxia", "Xinjiang", null, "Taiwan", null, null, null, "Hong Kong", "Australia", null, "foreign "};
Double isum = 0;
String info = "";
System. Text. regularexpressions. RegEx Rg = new system. Text. regularexpressions. RegEx (@ "^/d {17} (/d | x) $ ");
System. Text. regularexpressions. Match MC = RG. Match (CID );
If (! MC. Success)
{
Return "";
}
Cid = CID. tolower ();
Cid = CID. Replace ("X", "");
If (acity [Int. parse (CID. substring (0, 2)] = NULL)
{
Return "illegal region ";
}
Try
{
Datetime. parse (CID. substring (6, 4) + "-" + CID. substring (10, 2) + "-" + CID. substring (12, 2 ));
}
Catch
{
Return "invalid birthday ";
}
For (INT I = 17; I> = 0; I --)
{
Isum + = (system. Math. Pow (2, I) % 11) * Int. parse (CID [17-i]. tostring (), system. Globalization. numberstyles. hexnumber );
}
If (isum % 11! = 1)
Return ("invalid ID ");
Return (acity [Int. parse (CID. substring (0, 2)] + "," + CID. substring (6, 4) + "-" + CID. substring (10, 2) + "-" + CID. substring (12, 2) + "," + (Int. parse (CID. substring (16,1) % 2 = 1 bytes "male": "female "));
}
Call test:
Response. Write (checkcidinfo ("340524198002300019 "));
Response. Write (checkcidinfo ("34052419800101001x "));
For15BitCan be upgraded18BitVerify again becauseIsAlways busy, noYesMethod for writing 15-"18
Publish the rules as follows:
In accordance with the national standard GB 11643-1999 of the People's Republic of ChinaYesAccording to the Customs identity number, a citizen identity number is a combination of features and consists of a 17-digit ontology code and a digital verification code. Sort order from left to rightIs: Six-digit address code, eight-digit birth date code, three-digit sequence code, and one-digit verification code.
The address code indicates the Administrative Code of the county (city, flag, district) where the resident account of the encoding object is located. The birthdate code indicates the year, month, and day of the encoded object. The year is represented by four digits, and there is no delimiter between years, months, and days. The sequence number indicates the sequence number of persons born in the same year, month, or day within the region specified by the same address code. The odd number of the sequence code is assigned to men, and the even number is assigned to women. The verification code is calculated based on the first 17-digit code according to the ISO 7064: 1983.mod 11-2 verification code. The following is an example of this calculation method.
15BitID card code first expands the birth yearIsFour, simply add another 19, but this is not used by people born in 1900 (there are not many such life stars)
Body code of a male citizenship numberIs34052419800101001, first calculated according to formula (1:
SIGMA (AI x WI) (mod 11 ).......................................... (1)
Formula (1:
I ---- indicates the serial number of the character from the start to the left, including the verification code;
AI ---- indicates the number character value at position I;
Wi ---- indicates the weighting factor at position I. The value is calculated based on the formula Wi = 2 (n-1) (mod 11.
I 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
AI 3 4 0 5 2 4 1 9 8 0 0 1 0 0 1 1
Wi 7 9 10 5 8 4 2 1 6 3 7 9 10 5 8 4 2 1
AI x wi 21 36 0 25 16 16 2 9 48 0 0 9 0 5 0 0 2 1
Calculate according to formula (1:
SIGMA (AI x WI) = (21 + 36 + 0 + 25 + 16 + 16 + 2 + 9 + 48 + 0 + 0 + 9 + 0 + 5 + 0 + 0 + 2) = 189
189 usd11 = 17 + 2/11
SIGMA (AI x WI) (mod 11) = 2
Then, based on the calculation result, find the corresponding verification code from the following table. X indicates the calculation result.Is10:
SIGMA (AI x WI) (mod 11) 0 1 2 3 4 5 6 7 8 9 10
Verification Code character value: AI 1 0x9 8 7 6 5 4 3 2
Find the calculation result based on the above table.Is2 Verification CodeIsTherefore, the employee's citizenship number shouldIs34052419800101001x.