ID number 15-digit + 18-digit (C #)

Source: Internet
Author: User

ID number 15, 18 digits.

ID 18-bit authentication

The 18-digit ID standard is clearly stipulated in the gb11643-1999 "citizenship number", which was implemented by the National Quality and Technical Supervision Bureau 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 "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

15-digit + 18 method

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 ⑴:

∑ (AIXWI) (mod 11) ..... ...... ...... ...... ...... ...... ...... (1)

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).

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 1 0 0 1 A1

Wi. 7 9 10 5 8 4 2 1 6 3 7 9 10 5 8 4 2 1

AIXWI 0 2 9/0 0 9 0 5 0 0 2 A1

Calculated according to the formula (1):

∑ (AIXWI) = (21+36+0+25+16+16+2+9+48++0+0+9+0+5+0+0+2) = 189

189÷11 = 17 + 2/11

∑ (AIXWI) (mod 11) = 2

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.

C # code:


private string Per15to18 (String peridsrc)
{
int is = 0;

Weighted Factor constants
Int[] Iw=new int[]{7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2};
Checksum code constant
String lastcode= "10x98765432";
New ID Number
String peridnew;

Peridnew=peridsrc.substring (0,6);
Fill in the 6th and 7th places and fill in the ' 1 ', ' 9 ' two digits
Peridnew + = "19";

Peridnew + + peridsrc.substring (6,9);

Make a weighted sum
for (int i=0; i<17; i++)
{
is + = Int. Parse (peridnew.substring (i,1)) * Iw[i];
}

Modulo operation to obtain modulus value
int IY = is%11;
From the Lastcode, take the value of modulo index number, add to the last one of the ID card, that is the new ID number.
Peridnew + + lastcode.substring (iy,1);

return peridnew;
}




Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.