This section describes how to calculate the last verification code of an 18-digit ID card number.
A citizenship number is a combination of features and consists of a 17-digit ontology code and a 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.
Verification Method:
(1) 17-digit ontology weighted sum formula
S = sum (ai * WI), I = 0,..., 16, first sum the right of the first 17 digits
AI: indicates the number of ID card numbers at location I.
Wi: indicates the weighting factor at position I.
Wi: 7 9 10 5 8 4 2 1 6 3 7 9 10 5 8 4 2
(2) Computing Model
Y = Mod (S, 11)
(3) obtain the corresponding verification code through the modulo
Y: 0 1 2 3 4 5 6 7 8 9 10
Verification Code: 1 0x9 8 7 6 5 4 3 2
Below is CProgramCode:
// Char szsrc1 [] = "11010519491231002x ";
// Doverify (szsrc1 );
// Charszsrc2 [] = "440524188001010014 ";
// Doverify (szsrc2 );
Char doverify (const char * pszsrc)
{
Int Is = 0;
Int IW [] = {7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2 };
Static char szvercode [] = "10x98765432 ";
Int I;
For (I = 0; I <17; I ++)
{
Is + = (INT) (pszsrc [I]-'0') * IW [I];
}
Int Iy = is % 11;
// Printf ("% d % 11 = Iy = % d/N", is, Iy );
// Printf ("% C/N", szvercode [Iy]);
Return szvercode [Iy];
}