C # Implementation of the 18-bit ID card format verification algorithm
Source: Internet
Author: User
Algorithm 18-bit identity card standard in the national quality and technical supervision of the implementation of the July 1, 1999 gb11643-1999 "citizenship number" made clear provisions. 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 "Civil Status Number", and that the "Civil status number" is also gb11643-1999. Replace gb11643-1989 from the date of implementation. The main contents of gb11643-1999 's citizenship number are as follows:
One, scope
This standard stipulates the code object of the Citizen ID number, the structure and manifestation of the number, so that each encoded object obtains a unique and invariable legal number.
Second, the Encoding object
The code object of the citizenship number is a citizen with nationality of the People's Republic of China.
III. structure and representation of numbers
1, the structure of the number
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 digit parity code.
2. Address Code
The administrative division code of the county (city, Flag, district) of the resident account of the encoding object is executed according to the GB/T2260 regulations.
3. Birth date Code
Indicates the year, month, and day of the encoding object's birth, which is executed according to gb/t7408, and the year, month, and day codes are not separated by delimiters.
4. Sequential code
Indicates the sequence number assigned to a person born in the same same address code, the same month and the same day, and the odd distribution of order codes to men, even to females.
5. Check code
(1) The weighted summation formula of 17-digit body code
S = SUM (Ai * Wi), i = 0, ..., 16, first the sum of the first 17 digits
Ai: Indicates the ID number value of position I
Wi: A weighted factor representing position I
Wi:7 9 10 5 8 4 2 1 6 3 7 9 10 5 8 4-2
(2) Computational model
Y = mod (S, 11)
(3) The corresponding check code is obtained through the model
Y:0 1 2 3 4 5 6 7 8 9 10
Check code: 1 0 X 9 8 7 6 5 4 3 2
Iv. examples are as follows:
Chaoyang District, Peking City: 11010519491231002X
Guangdong Province Shantou: 440524188001010014
To invoke the test:
Response.Write (Checkcidinfo ("340524198002300019"));
Response.Write (Checkcidinfo ("34052419800101001x"));
15-bit authentication can be promoted to 18-bit before verification, because it has been very busy, there is no way to write 15-18
Publish the Rules:
According to the standard GB 11643-1999〗 of the People's Republic of China, the citizen identification number is a characteristic combination code, which consists of 17 digit ontology code and a digital check code. The order is from left to right: six digit address code, eight digit birth date code, three digit sequential code and one digit parity code.
The address code represents the administrative division code of the county (city, Flag, district) of the resident residence of the encoding object. The date code represents the year, month, and day of the encoding object's birth, where the year is represented by a four-digit number, and the year, month, and day are not separated. The sequential code represents the sequence number of persons born in the same same address code, in the range of the area identified by the same one. The odd number of sequential codes is given to men, even to females. The check code is based on the front 17 digit code, according to the ISO 7064:1983.mod 11-2 check code to calculate the inspection code. The following example illustrates the calculation method.
The 15-digit ID Code First expands the year of birth to 4 digits, simply by adding a 19, but this is not used for people born in 1900 (the birthday is not much)
A male citizen ID number is 34052419800101001, first calculated according to the formula ⑴:
Formula (1):
I----the number of digits from the to left including the check code;
AI----represents the number character value on position I;
The Wi----shows the weighting factor in position I, whose numerical value is calculated according to the formula wi=2 (n-1) (mod 11).
Then, based on the results of the calculation, the corresponding checksum code is detected from the table below, where x indicates that the result is 10:
∑ (AIXWI) (mod 11) 0 1 2 3 4 5 6 7 8 9 10
Parity code character value AI 1 0 X 9 8 7 6 5 4 3 2
According to the table above, the verification code with the result of 2 is found to be that the citizenship number of the person should be 34052419800101001X.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.