|
#include<file.au3>
DIM $NAME,$AREA
if not _FileReadToArray("姓名.TXT",$NAME) THEN
MSGBOX(4096,"错误","读取文件“姓名.TXT”时发生错误!")
Exit
EndIf
if not _FileReadToArray("行政代码.TXT",$AREA) THEN
MSGBOX(4096,"错误","读取文件“行政代码.TXT”时发生错误!")
Exit
EndIf
$line = "[身份证]" & @crlf
FOR $X = 1 TO 500
$m = StringStripWS(StringStripCR($NAME[Random(1,$NAME[0],1)]),12) ;;取随机姓名
if stringlen($m) > 6 or stringlen($m) < 4 then ContinueLoop ;;姓名不为两或三个字则ContinueLoop
$areastr = StringStripWS(StringStripCR($AREA[Random(1,$AREA[0],1)]),12) ;;取随机地区代码
if stringlen($areastr) <> 6 then ContinueLoop ;;地区代码不为六位则ContinueLoop
$mon = Random(1,12,1) ;取随机月
IF $MON = 2 THEN ;;如果随机月为二月,则随机日最大取28,否则最大30
$YNTWO = 28
ELSE
$YNTWO = 30
ENDIF
IF STRINGLEN($mon) = 1 THEN $mon = "0" & $mon ;;如果随机月为一位字符则前面补零
$day = Random(1,$ynTWO,1) ;;;取随机日
IF STRINGLEN($day) = 1 THEN $day = "0" & $day
$SERIAL = Random(01,99,1) ;;取随机顺序码
IF STRINGLEN($SERIAL) = 1 THEN $SERIAL = "0" & $SERIAL
$GERDER = RANdom(1,9,1) ;;取随机性别
$BODY = $areastr & Random(1970,1987,1) & $mon & $day & $SERIAL & $GERDER ;身份证前十七位本体码
$line = $line & $x & "=" & $m & "," & $BODY & MAKECHECKCODE($BODY) & @crlf
NEXT
if not _FileCreate("east_bar.ini") Then
MSGBOX(4096,"错误","创建文件“EAST_BAR.INI”时发生错误!")
Exit
EndIf
if not filewrite("east_bar.ini",$line) Then
MSGBOX(4096,"错误","写入文件“EAST_BAR.INI”时发生错误!")
EndIf
Exit
;;;本函数为身份证号码校验码生成函数
;;;调用方式MAKECHECKCODE($ID),$ID为身份证号码前十七位,失败返回-1,成功则返回校验码
FUNC MAKECHECKCODE($iD)
IF STRINGLEN($id) <> 17 THEN RETURN -1
LOCAL $W1[18],$code[12],$A[18],$sum = 0,$y,$checkcode
$W1[1] = 7
$W1[2] = 9
$W1[3] = 10
$W1[4] = 5
$W1[5] = 8
$W1[6] = 4
$W1[7] = 2
$W1[8] = 1
$W1[9] = 6
$W1[10] = 3
$W1[11] = 7
$W1[12] = 9
$W1[13] = 10
$W1[14] = 5
$W1[15] = 8
$W1[16] = 4
$W1[17] = 2
$code[1] = 1
$code[2] = 0
$code[3] = "x"
$code[4] = 9
$code[5] = 8
$code[6] = 7
$code[7] = 5
$code[8] = 5
$code[9] = 4
$code[10] = 3
$code[11] = 2
for $I = 1 to stringlen($id)
$A[$I] = STRINGMID($id,$I,1)
$SUM = $sum + $A[$I] * $w1[$I]
NEXT
$y = MOD ($sum,11)
$checkcode = $code[$y + 1]
return $checkcode
ENDFUNC |
|