Blackphoenix published The 2008-2-19
C # Chinese identity card verification, including the Province verification and Verification code validation, in line with the gb11643-1999 standard ...
It's written today.
C # Chinese identity card verification, including the Province verification and Verification code validation, in line with the gb11643-1999 standard ...
Theoretical part:
15-bit ID number = 6-bit area code + 6-digit birthday + 3-digit number
18-bit ID number = 6-bit area code + 8-digit birthday + 3-digit + 1-bit inspection code
The country code in the provinces and cities the first two-digit code is:
Beijing 11 Jilin 22 Fujian 35 Guangdong 44 Yunnan 53 Tianjin 12 Heilongjiang 23 Jiangxi 36 Guangxi 45 Tibet 54 Hebei 13 Shanghai 31 Shandong 37 Hainan 46 Shaanxi West 61 Shanxi 14 Jiangsu 32 Henan 41 Chongqing 50
Gansu 62 Inner Mongolia 15 Zhejiang 33 Hubei 424 Sichuan 51 Qinghai 63 Liaoning 21 Anhui 34 Hunan 43 Guizhou 52 Ningxia 64 Xinjiang 65 Taiwan 71 Hong Kong 81 Macau 82 Foreign 91
The 18-digit ID standard is clearly stipulated in the gb11643-1999 "citizenship number", which was implemented by the National Bureau of Quality and Technical supervision on July 1, 1999.
Gb11643-1999 's "Citizenship number" is a revised version of gb11643-1989 's social Security number, which states that the original standard name "Social Security Number" is renamed "Citizenship Number", and that the "Citizenship number" is gb11643-1999 from the date of implementation gb11643-1989.
The citizenship number is a characteristic combination code, which consists of a 17 digit ontology code and a check code. The order is from left to right: six digit address code, eight digit birth date code, three digit sequential code and one check code. The meaning is as follows:
1. Address code: Represents the code object of the county (city, Flag, district) of the resident's administrative area codes, according to the provisions of gb/t2260 implementation.
2. Date of birth code: Indicates the year, month, day of the encoding object's birth, according to Gb/t7408 's stipulation executes, the year, the month, the day respectively uses 4 bits, 2 digits, 2 digits to indicate, does not have the separator character between.
3. Sequential code: means that in the area identified by the same address code, the order number of the same year, the same month, the person born on the same day, the odd distribution of the order code to the male, even to the female.
How the checksum is calculated:
1. Weighted summation of the first 17 digit ontology code
The formula is: S = Sum (Ai * Wi), i = 0, ..., 16
Where AI represents the ID number value of position I, Wi represents the weighting factor in position I, and the corresponding values are:
7 9 10 5 8 4 2 1 6 3 7 9 10 5 8 4-2
2. Modulo with 11 pairs of calculation results
Y = mod (S, 11)
3. According to the model's worth to the corresponding check code corresponding relationship is:
Y-Value: 0 1 2 3 4 5 6 7 8 9 10
Check code: 1 0 X 9 8 7 6 5 4 3 2