ID 15-bit converted to 18-bit code (VBScript)

Source: Internet
Author: User

Today on the forum someone wanted this code, someone posted a vb, the diagram conveniently rewritten as a VBS, and canceled 1900 years ago judgment, I hope the original VB author do not take offense.

as follows:

<% @LANGUAGE = "VBSCRIPT" codepage= "936"%>
<%
Function getnewidcard (idcard)
         Dim I, S, Wi,wf,result
        wi= Split ( "7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2", ",", -1,1)
        wf= Split ("1,0,x, 9,8,7,6,5,4,3,2 ",", ", -1,1)
        idcard = Mid (Idcard, 1, 6) &" + "& Mid (Idcard, 7, 9)
        s=0
        For i = 0 To UBound (WI)
      
   s = CInt (WI (i)) *cint (Mid (Idcard, i + 1, 1) +s
    
        Next
   Getnewidcard=idcard & Wf (S Mod)
       
    End Function

Idcard=request ("Idcard")
If Idcard<>empty Then
Newidcard=getnewidcard (Idcard)
Response. Write (Newidcard)
End If
%>
<form action= "" method= "POST" >
<input name= "Idcard" value= "340524800101001" >
</form>
----------------------------------
Operation Result:

------------------------
Below is the rule that forwards the sfply (The Wind Leaves):

According to the national standard GB 11643-1999〗 of the People's Republic of China, the citizenship number is a feature combination code, consisting of 17-bit digital body code and a digit check code. The sorting order is from left to right: six-digit address code, eight-digit birth date code, three-digit sequential code, and one-digit check code.

The address code represents the code of the county (city, Flag, district) of the resident household account. The date code represents the year, month, and day of the birth of the encoded object, where the year is represented by a four-digit number, with no separator between the year, month, and day. Sequential codes denote the sequence numbers of persons born in the same year, month, and day, within the range of the area identified by the same address code. The odd number of sequential codes is given to males, even to females. Verification code is based on the previous 17-digit code, according to the ISO 7064:1983.mod 11-2 Check code calculated by the test code. The calculation method is illustrated below.

The 15-bit ID code first expands the birth year to 4, simply by adding a 19, but this is not used for people born in 1900 (such a birthday is not much)

A male citizenship number body code is 34052419800101001, first calculated according to the formula ⑴:

∑ (AIXWI) (mod 11) ..... ..... ..... ....... ............... (1)

In equation (1):
I----indicates the number of characters from the left and right includes the check code, including the position ordinal;
AI----represents the number character value at position I;
Wi----The weighting factor at position I, calculated based on the formula wi=2 (n-1) (mod 11).

I 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1

Ai 3 4 0 5 2 4 1 9 8 0 0 1 0 1 0 0 1 A1

Wi 7 9 10 5 8 4 2 1 6 3 7 9 10 5 8 4 2 1

Aixwi 0 2 9 0 0 9 0 5 0 0 2 A1

Calculated according to the formula (1):

∑ (AIXWI) = (21+36+0+25+16+16+2+9+48++0+0+9+0+5+0+0+2) = 189

189÷11 = 17 + 2/11

∑ (AIXWI) (mod 11) = 2

Then, based on the results of the calculation, the corresponding check code is detected from the table below, where x indicates the result of the calculation is 10:

∑ (AIXWI) (mod 11) 0 1 2 3 4 5 6 7 8 9 10
Check code character value ai 1 0 X 9 8 7 6 5 4 3 2
According to the above table, find out that the calculation result is 2 of the check code so that the person's citizenship number should be 34052419800101001X.

  A[0]*7+A[1]*9+A[2]*10+A[3]*5+A[4]*8+A[5]*4+A[6]*2+A[7]*1+A[8]*6+A[9]*3
  +A[10]*7+A[11]*9+A[12 ]*10+a[13]*5+a[14]*8+a[15]*4+a[16]*2
 %11

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.