(i) Structure of the 18 ID card number
The citizenship number is a feature combination code consisting of a 17-bit digital body code and a checksum code.
Order from left to right: six-digit address code, eight-digit birth date code, three-digit sequence code, and one check code.
1, the address code indicates the code object resident account County (city, Flag, district) of the administrative Area division codes, according to the provisions of gb/t2260 implementation.
2. Birth date code indicates the year, month and day of the birth of the encoded object, according to the provisions of gb/t7408, the year, month, day code between the use of the separator.
3, the sequence code in the same address code is identified in the range, the same year, the same month, the same day birth of the number of people born, sequential code of the odd assigned to men, even assigned to women.
4. Verification code Calculation steps
(1) Weighted summation formula for 17-bit digital body code
S = SUM (Ai * Wi), i = 0, ..., 16, the first 17 digits of the right sum
Ai: The digital value of the ID number (0~9) at position I
Wi:7 9 10 5 8 4 2 1 6 3 7 9 10 5 8 4 2 (indicates the weighting factor at position I)
(2) calculate modulo Y = mod (S, 11)
(3) According to the module, find the corresponding check code 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
(ii) Obtain the last check code program instance based on the 17-bit digital Ontology code
public class Id18 { int[] weight={7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2}; 17-digit Body Code weight char[] validate={' 1 ', ' 0 ', ' X ', ' 9 ', ' 8 ', ' 7 ', ' 6 ', ' 5 ', ' 4 ', ' 3 ', ' 2 '}; MOD11, corresponding check code character value public char getvalidatecode (String id17) { int sum = 0; int mode = 0; for (int i = 0; i < id17.length (); i++) { sum=sum+integer.parseint (string.valueof (Id17.charat (i))) *weight[i]; } mode = sum%; return validate[mode]; } public static void Main (string[] args) { Id18 tes t= new Id18 (); System.out.println ("The Identity Card verification Code:" +test.getvalidatecode ("14230219700101101")); This ID check code: 3 }}
(iii) Description
1. The program can obtain the corresponding verification code according to the existing 17-bit digital ontology code.
2. The program can eliminate the incorrect verification code ID number.
3.15-digit ID The year of birth is 2 digits after the year, with no last 1-digit checksum.
4. Complete ID 18 bits, the last check digit may be non-numeric. One of our projects, the database saves the first 17 digits, so that some SQL statements (such as inner join) have accelerated!!!
Verification and change of ID number