Java-based 18-bit ID card format Verification Algorithm
Source: Internet
Author: User
Java-based 18-bit ID card format verification algorithm-general Linux technology-Linux programming and kernel information. The following is a detailed description. A citizenship number is a combination of features and 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.
1. Address Code
Indicates the Administrative Code of the county (city, flag, district) where the resident account of the encoding object is located, which is executed according to GB/T 2260.
2. Date of birth
Indicates the year, month, and day when the encoding object is born. The code is executed according to GB/T 7408. There is no separator between the year, month, and day codes.
For example, if a person is born on January 1, October 26, 1966, the birth date code is 19661026.
3. Sequence Code
Indicates the sequence number of the person born on the same year, the same month, and the same day within the region specified by the same address code. The odd number of the sequence code is allocated to men, and the even number is allocated to women.
4. Verification Code
The verification code uses the ISO 7064: 1983, MOD 11-2 Verification code system.
(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
If (eightcardid. length () = 17 ){
Int sum = 0;
For (int I = 0; I <17; I ++ ){
String k = eightcardid. substring (I, I + 1 );
Ai = Integer. parseInt (k );
}
For (int I = 0; I <17; I ++ ){
Sum = sum + wi * ai;
}
Remaining = sum % 11;
}
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.