ID card 15-bit conversion to 18-bit code (VBScript)

xiaoxiao2021-03-06  94

Today, someone wants this code. Someone will post a VB, and the map is easily rewritten into VBS, and canceled the judgment of 1900, I hope that the original VB author should not be able to see.

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) &" 19 "& 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 11) End Function

IDCARD = Request ("IDCARD") if idcard <> EMPTY THENNEWIDCARD = GetneWidCard (IDCARD) Response.write (newidcard) end if%>

---------------------------------- Run results: ----- ------------------ The following is the rules of the SFPLY (with the wind rid of the wind): According to the National Standard GB 11643-1999, the Citizenship Number of the People's Republic of China The regulations, the citizen identity number is the feature group code, consists of seventeen digital homide and one digital check code. Arrange the order from left to right as: six digit address code, eight digit born date code, three digital sequence code and one digital check code.

The address code represents the administrative region of the county (city, flag, district) in the county (city, flag, district) of the coding object. The birthday period indicates the year, month, day of the birthday, month, and the year, the year, the year, month, and day without separator. The sequence code indicates the sequence number of the person born in the same year, month, and day. The odd number of sequence codes is given to men, even giving women. The check code is based on the seventeenth digit of the previous seventeen digits, calculated by the ISO 7064: 1983.MOD 11-2 check code. The calculation method will be described below.

15 identity card coding first expanded the birth year to 4 digits, simple is to increase a 19, but this is not used for people born in 1900 (such birthday is not much)

A male citizenship number is 34052419800101001, first, according to formula (1):

Σ (AI × Wi) (MOD 11) ........................................ (1)

Equation (1): i ---- Indicates the number character from the zip number, including the calibration code; AI ---- represents the number character value at the first position; Wi ---- show The weighting factor at the i position is 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

Ai × Wi 21 36 0 25 16 16 2 9 48 0 0 9 0 5 0 0 2 A1

Calculated according to equation (1):

Σ (AI × Wi) = (21 36 0 25 16 16 2 9 48 5 0 0 2) = 189

189 ÷ 11 = 17 2/11

Σ (AI × Wi) (MOD 11) = 2

The corresponding check code is then isolated from the following table according to the calculated result, where x represents the calculation result 10:

Σ (AI × Wi) (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 top table, the calculation result is 2 schools The code for the citizenship number of the person 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

转载请注明原文地址:https://www.9cbs.com/read-95625.html

New Post(0)