barkure

barkure

telegram
github

MOD 11-2 Verification in ID Card

GB11643-1999 is the national standard for the current citizen identification number in our country. We can easily find this document.


Identity#

The identity card number, also known as the citizen identification number, consists of 18 digits. The identity card number is divided into two parts: the main code and the check code.

Main Code#

The first seventeen digits of the identity card number are the main code (master number), arranged from left to right in the following order: six-digit address code, eight-digit birth date code, and three-digit sequence code. This part is relatively simple, so I will not elaborate on it.

Check Code#

The eighteenth digit of the identity card number is the check code (check number), which can be obtained by performing a specified mathematical operation on the first seventeen digits. Specifically, the MOD 11-2 check code algorithm is used.

MOD 11-2 Check#

First, each digit of the identity card number has its fixed weighting factor $Wi$, which is equal to the remainder when $2$ raised to the power of $18-i$ is divided by $11$. Here, $i$ represents the position of each digit in the number, as follows:

Wi=218i(mod11)W_i = 2^{18-i}\pmod {11}

Multiply each digit $a_i$ by its corresponding weighting factor $W_i$ and sum them up to obtain the value $S$:

S=i=117Wi×aiS = \sum_{i=1}^{17}W_i×a_i

Calculate the remainder when $S$ is divided by $11$:

S(mod11)S\pmod{11}

Then subtract this remainder from $12$:

12S(mod11)12-S\pmod{11}

Finally, calculate the remainder when this difference is divided by $11$, and obtain the final check code $a_{18}$:

a18=(12S(mod11))(mod11)a_{18} = (12-S\pmod{11})\pmod{11}

Now that we know the algorithm, let's give it a try (using Appendix A mentioned in the national standard as an example):

Suppose a citizen's identity card number is 11010519491231002X.

We can calculate the weighting factors for the first seventeen digits

Let's take the fifth digit as an example and calculate the weighting factor $W_5$:

2185=213=81922^{18-5} = 2^{13} = 8192

$W_5$ should be the remainder when 8192 is divided by 11:

W5=8192(mod11)=8W_5 = 8192\pmod{11} = 8

Similarly, after some calculations, we can easily obtain the following table showing the relationship between $W_i$ and $a_i$:

$a_i$1234567891011121314151617
$W_i$7910584216379105842

Then calculate the value $S$:

S=i=117Wi×ai=71+91+100+51+80+45+21+19+64+39+71+92+103+51+80+40+22=167S = \sum_{i=1}^{17}W_i×a_i = 7*1+9*1+10*0+5*1+8*0+4*5+2*1+1*9+6*4+3*9+7*1+9*2+10*3+5*1+8*0+4*0+2*2 = 167

Divide 167 by 11, the quotient is 15 and the remainder is 2:

167(mod11)=2167\pmod{11} = 2

Subtract 2 from 12, the difference is 10. Divide 10 by 11, the quotient is 0 and the remainder is 10:

(122)(mod11)=10(12-2)\pmod{11} = 10

Therefore, the check code $a_{18}$ is equal to 10. Since the identity card number is limited to 18 digits, we replace 10 with the Roman numeral X. So the check code for this citizen's identity card number is X.


Note: This text is referenced from the following sources:

  • National Standard of the People's Republic of China "GB 11643-1999 Citizen Identification Number"
  • Wikisource "GB 11643-1999 Citizen Identification Number"
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.