Calculation Method of ID card 18th-bit (Verification Code)

Source: Internet
Author: User

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: 7-9-10-5-8-4-2-1-6-3-7-9-10-5-8-4-2.
2. Add the result of multiplying the 17-digit number and the coefficient.
3. How much is the remainder can be seen by adding and dividing by 11?
4. The remainder can only contain the 11 numbers 0-1-2-3-4-5-6-7-8-9-10. The numbers of the last ID card are 1-0-x-9-8-7-6-5-4-3-2.
5. 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.
For example, the ID number of a male is 34052419800101001x. Let's see if this ID card is a valid ID card.
First, we get the product of the first 17 bits and the product is 189. Then we divide 189 by 11 and the result is 17 + 2/11, that is, the remaining number is 2. Finally, the corresponding rule shows that the number of remainder 2 is X. Therefore, it can be determined that this is a qualified ID card number.

 

VaR arr = [,] var arr2 = '201712119880915005x '. split (''); Total = 0; For (VAR I = 0; I <arr. length; I ++) {total + = ~~ Arr [I] * ~~ Arr2 [I]} console. log (Total % 11) console. log ([, 'x',] [Total % 11]) // The value of the last bit

Calculation Method of ID card 18th-bit (Verification Code)

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.