Secret of ID card number

Source: Internet
Author: User

Identity Card Number composition rules:

There are 18 ID cards in mainland China and 15 old ones. The principle of how ID card 18th is calculated is as follows: according to the provisions on citizenship numbers in the National Standard of the People's Republic of China (GB 11643-1999), citizenship numbers are feature combination codes, it consists of a 17-digit ontology code and a digital verification code. The six-digit address code, eight-digit birth date code, three-digit sequence code, and one-digit verification code are arranged from left to right.
 

The address code (the first six digits of the ID card) indicates the administrative area of the county (city, flag, district) where the resident account of the encoding object is located.Code. (The codes of all regions can be found with the latest Administrative Code documents of counties and above .)
The Birth Date Code (the seventh to 14th digits of the ID card) indicates the year, month, and day of the birth of the encoding object. The year is represented by four digits, and there is no separator between the year, month, and day. For example, 19810511 is used for representation.
The sequence code (15th to 17 digits of the ID card) is the sequence number of persons born in the same year, month, or day within the region indicated by the same address code. Among them, the 17th-digit odd number is given to men, and the even number is given to women.
The verification code (the last digit of the ID card) is the verification code calculated based on the first 17-digit code according to the ISO 7064: 1983.mod 11-2 verification code.

The calculation method of a 18th-bit number is as follows:
1. Multiply the 17 digits of the previous ID card number by different coefficients. The coefficients from the first digit to the second digit are respectively 7 9 10 5 8 4 2 1 6 3 7 9 10 8 4 2
2. Add the result of multiplying the 17-digit number and the coefficient.
3. Add and divide by 11 to check the remainder?
The remainder may only contain the 11 numbers 0 1 2 3 4 5 6 7 8 9 10. The numbers corresponding to the last ID card respectively are 1 0x9 8 7 6 5 4 3 2.
5. I learned from the above that if the remainder is 2, the X of the Roman numerals will appear on the 18th digits of the ID card. If the remainder is 10, the last digit of the ID card is 2.

 

Bytes -----------------------------------------------------------------------------------------------------------------

Based on the above rules, we can conclude that:

Each region specified by the address code can have a maximum of 99*2*10 = 1980 different ID card numbers each day. That is to say, each region can have up to 1980 babies ?, It seems like this.

 

BTW: Write a function to implement the check bit (18th bits)AlgorithmThe algorithm is inaccurate during the test:

# An algorithm written in Python

Def calc_chk (strcardno): <br/> assert (LEN (strcardno) = 18) </P> <p> ls_no = map (INT, strcardno [: 17]) <br/> ls_factor = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2,] <br/> ret_sum = reduce (lambda X, Y: X + Y, map (lambda X, Y: x * y, ls_factor, ls_no )) % 11 </P> <p> ls_match = ['1', '0', 'x', '9', '8', '7', '6 ', '5', '4', '3', '2'] <br/> return ls_match [ret_sum]

 

 

Enter the first 17 digits of the ID number.

Output: Verification Code

Verification: whether the output verification code is consistent with the last digit of the ID card number

 

 

 

 

 

 

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.