|
namejm
荣誉版主
       batch fan
积分 5226
发帖 1737
注册 2006-3-10 来自 成都
状态 离线
|
    『楼 主』:
[原创]身份证号码信息查询器[07-3-6更新]
使用 LLM 解释/回答一下
使用方法:请把附件中的date.txt与本代码保存在同一目录下使用。
注意事项:本数据库源于中华人民共和国国家统计局2006年12月31日的最新数据,在此之前,若因行政区划有变动而造成原有的行政区划代码被取消、变更,会导致部分合法ID被认为非法。
@echo off
:: 功能:
:: 1、根据号码查询性别、出生日期和户籍所在地
:: 2、15位号码升18位
:: 3、根据户籍所在地和出生日期批量生成身份证号码
::
:: 已知bug:
:: 1、输入检测不严格
:: 2、生成ID的速度较慢
::
:: Code by JM 2007-3-4 CMD@XP
::
:: 更新历史:
::
:: 07.3.6
:: 更正了15位号码升18位时始终显示非法号码的错误;
mode con lines=20 cols=50
title 身份证号码信息查询器
setlocal enabledelayedexpansion
set check_num=10X98765432
:Main
cls
set flag=
set IDflag=
echo.&echo.&echo.&echo.
echo 1、通过18位号码查询基本信息
echo.
echo 2、15位号码升18位
echo.
echo 3、生成指定地区的身份证号码
echo.&echo.&echo.
echo __________________________________________________
echo.
set choice=
set /p choice= 请输入功能代码(退出请直接回车):
if "%choice%"=="1" goto Get_Info
if "%choice%"=="2" goto UpDate
if "%choice%"=="3" goto Creat_ID
if defined choice goto Main
exit
:Get_Info
cls
echo.&echo.&echo.&echo.&echo.
set ID=
set /p ID= 请输入18位身份证号码:
call :Check_ID %ID%
if defined flag (
call :PickUp_Info
) else call :ERR
echo 按任意键返回主界面...
pause>nul
goto Main
:UpDate
cls
echo.&echo.&echo.&echo.&echo.
set IDflag=15
set ID=
set /p ID= 请输入15位身份证号码:
set ID_15=%ID%
set ID=%ID:~0,6%19%ID:~6%
call :Check_ID %ID%
if defined flag (
call :PickUp_Info
) else call :ERR
echo 按任意键返回主界面...
pause>nul
goto Main
:Creat_ID
cls
echo.&echo.
echo 地名只能检索到县级及其之上的行政区划;必须
echo.
echo 按照行政级别的顺序输入,可以跳级输入,多个关键
echo.
echo 字用空格分隔。比如:四川 成都 青羊区 或者
echo.
echo 四川 青羊区 或者 成都 。
echo.
echo 生日必须是6位数字的格式,比如:20070130 。
echo.
echo __________________________________________________
echo.
set place=
set birthday=
set exp=
set /p place= 请输入地区关键字:
echo.
set /p birthday= 请输入8位格式的出生日期:
if "%birthday:~7,1%"=="" (call :ERR & pause & goto Main)
if not "%birthday:~0,8%"=="%birthday%" (call :ERR & pause & goto Main)
set /a day=1%birthday% 2>nul||(call :ERR & pause & goto Main)
if not "%day:~1%"=="%birthday%" (call :ERR & pause & goto Main)
cls
echo.&echo.
echo 符合条件的号码有^(中途可按 Ctrl^+C 暂停执行^):
echo.
for %%i in (%place%) do set exp=!exp!.*%%i
for /f "tokens=1*" %%i in ('findstr "%exp:~2%" date.txt') do (
set ID_place=%%i
set ID_tmp=!ID_place:~0,1!
for /l %%j in (1,1,9) do (
if !ID_tmp! equ %%j call :IDs
)
)
if not defined flag (
echo.&echo.&echo.
echo 数据库中检索不到关键字为 %place% 的地名!
echo.&echo.&echo.
)
echo 按任意键返回主界面...
pause>nul
goto Main
rem ==== 检测号码是否合法 ====
:Check_ID
set ID=%1
set ID_tmp=%1
if defined IDflag (
if "%ID:~16,1%"=="" set flag=&goto :eof
if not "%ID:~0,17%"=="%1" set flag=&goto :eof
) else (
if "%ID:~17,1%"=="" set flag=&goto :eof
if not "%ID:~0,18%"=="%1" set flag=&goto :eof
if /i "%ID:~-1%"=="x" set ID_tmp=%ID:~0,-1%
)
set /a ID_tmp_1=1!ID_tmp:~0,6! 2>nul||(set flag=&goto :eof)
set /a ID_tmp_2=1!ID_tmp:~6,8! 2>nul||(set flag=&goto :eof)
set /a ID_tmp_3=1!ID_tmp:~14! 2>nul||(set flag=&goto :eof)
if not "!ID_tmp_1:~1!!ID_tmp_2:~1!!ID_tmp_3:~1!"=="!ID_tmp!" set flag=&goto :eof
set sum=0
set str_wi=7 9 10 5 8 4 2 1 6 3 7 9 10 5 8 4 2 1
for /l %%i in (0,1,16) do (
set ai=!ID:~%%i,1!
call :Get_Num %%i !str_wi!
set /a product=!ai!*!wi! 2>nul
set /a sum+=!product!
)
set /a mod=%sum%%%11
set last_num=!check_num:~%mod%,1!
if defined IDflag (
set ID=%ID%%last_num%
set flag=1
goto :eof
)
if /i "%ID:~-1%"=="%last_num%" (
set flag=1
) else set flag=
goto :eof
:Get_Num
:: 提取 %str_wi% 中对应位置上的数值
for /l %%i in (1,1,%1) do shift
set wi=%2
goto :eof
:PickUp_Info
set char=%ID:~-2,1%
set /a mod=%char%%%2
if %mod% equ 0 (
set SEX=女
) else set SEX=男
for /f "tokens=1*" %%i in ('findstr "%ID:~0,6%" date.txt') do (
set flag=exist
cls
echo.&echo.&echo.&echo.
if defined IDflag (
echo 身份证号码:%ID_15%
echo.
echo 升位后号码:%ID%
) else echo 身份证号码:%ID%
echo.
echo 性 别: %SEX%
echo.
echo 出生日期:%ID:~6,4% 年 %ID:~10,2% 月 %ID:~12,2% 日
echo.
echo 户籍所在地:%%j
echo.&echo.&echo.&echo.
)
if not "%flag%"=="exist" call :ERR
goto :eof
rem ==== 生成合法的号码 ====
:IDs
for /l %%i in (0,1,999) do (
for %%j in (0 1 2 3 4 5 6 7 8 9 X) do (
set ID=00%%i%%j
call :Check_ID %ID_place%%birthday%!ID:~-4!
if defined flag echo %ID_place%%birthday%!ID:~-4!
)
)
goto :eof
rem ==== 出错提示 ====
:ERR
echo.&echo.
echo 非法号码
echo.&echo.&echo.
goto :eof
Last edited by namejm on 2007-3-6 at 10:01 PM ]
Usage method: Please save the date.txt in the attachment in the same directory as this code for use.
Precautions: This database originates from the latest data of the National Bureau of Statistics of the People's Republic of China on December 31, 2006. Before this, if the original administrative division code is canceled or changed due to changes in the administrative division, some legal IDs will be considered illegal.
@echo off
:: Function:
:: 1. Query gender, date of birth and place of household registration according to the number
:: 2. Upgrade 15-digit number to 18-digit
:: 3. Batch generate ID card numbers according to place of household registration and date of birth
::
:: Known bugs:
:: 1. Input detection is not strict
:: 2. The speed of generating ID is slow
::
:: Code by JM 2007-3-4 CMD@XP
::
:: Update history:
::
:: 07.3.6
:: Corrected the error that it always shows an illegal number when upgrading a 15-digit number to an 18-digit number;
mode con lines=20 cols=50
title ID Card Number Information Query Tool
setlocal enabledelayedexpansion
set check_num=10X98765432
:Main
cls
set flag=
set IDflag=
echo.&echo.&echo.&echo.
echo 1. Query basic information through 18-digit number
echo.
echo 2. Upgrade 15-digit number to 18-digit
echo.
echo 3. Generate ID card number of specified area
echo.&echo.&echo.
echo __________________________________________________
echo.
set choice=
set /p choice= Please enter the function code (press Enter directly to exit):
if "%choice%"=="1" goto Get_Info
if "%choice%"=="2" goto UpDate
if "%choice%"=="3" goto Creat_ID
if defined choice goto Main
exit
:Get_Info
cls
echo.&echo.&echo.&echo.&echo.
set ID=
set /p ID= Please enter 18-digit ID card number:
call :Check_ID %ID%
if defined flag (
call :PickUp_Info
) else call :ERR
echo Press any key to return to the main interface...
pause>nul
goto Main
:UpDate
cls
echo.&echo.&echo.&echo.&echo.
set IDflag=15
set ID=
set /p ID= Please enter 15-digit ID card number:
set ID_15=%ID%
set ID=%ID:~0,6%19%ID:~6%
call :Check_ID %ID%
if defined flag (
call :PickUp_Info
) else call :ERR
echo Press any key to return to the main interface...
pause>nul
goto Main
:Creat_ID
cls
echo.&echo.
echo Place names can only be retrieved to county-level and above administrative divisions; must
echo.
echo Input in the order of administrative levels, can jump levels, and multiple keywords are separated by spaces. For example: Sichuan Chengdu Qingyang District or
echo.
echo Sichuan Qingyang District or Chengdu.
echo.
echo Birthday must be in the format of 6 digits, for example: 20070130.
echo.
echo __________________________________________________
echo.
set place=
set birthday=
set exp=
set /p place= Please enter area keywords:
echo.
set /p birthday= Please enter 8-digit format date of birth:
if "%birthday:~7,1%"=="" (call :ERR & pause & goto Main)
if not "%birthday:~0,8%"=="%birthday%" (call :ERR & pause & goto Main)
set /a day=1%birthday% 2>nul||(call :ERR & pause & goto Main)
if not "%day:~1%"=="%birthday%" (call :ERR & pause & goto Main)
cls
echo.&echo.
echo There are ^(can press Ctrl^+C to pause execution halfway^) conforming numbers:
echo.
for %%i in (%place%) do set exp=!exp!.*%%i
for /f "tokens=1*" %%i in ('findstr "%exp:~2%" date.txt') do (
set ID_place=%%i
set ID_tmp=!ID_place:~0,1!
for /l %%j in (1,1,9) do (
if !ID_tmp! equ %%j call :IDs
)
)
if not defined flag (
echo.&echo.&echo.
echo The place name with the keyword %place% is not found in the database!
echo.&echo.&echo.
)
echo Press any key to return to the main interface...
pause>nul
goto Main
rem ==== Check if the number is legal ====
:Check_ID
set ID=%1
set ID_tmp=%1
if defined IDflag (
if "%ID:~16,1%"=="" set flag=&goto :eof
if not "%ID:~0,17%"=="%1" set flag=&goto :eof
) else (
if "%ID:~17,1%"=="" set flag=&goto :eof
if not "%ID:~0,18%"=="%1" set flag=&goto :eof
if /i "%ID:~-1%"=="x" set ID_tmp=%ID:~0,-1%
)
set /a ID_tmp_1=1!ID_tmp:~0,6! 2>nul||(set flag=&goto :eof)
set /a ID_tmp_2=1!ID_tmp:~6,8! 2>nul||(set flag=&goto :eof)
set /a ID_tmp_3=1!ID_tmp:~14! 2>nul||(set flag=&goto :eof)
if not "!ID_tmp_1:~1!!ID_tmp_2:~1!!ID_tmp_3:~1!"=="!ID_tmp!" set flag=&goto :eof
set sum=0
set str_wi=7 9 10 5 8 4 2 1 6 3 7 9 10 5 8 4 2 1
for /l %%i in (0,1,16) do (
set ai=!ID:~%%i,1!
call :Get_Num %%i !str_wi!
set /a product=!ai!*!wi! 2>nul
set /a sum+=!product!
)
set /a mod=%sum%%%11
set last_num=!check_num:~%mod%,1!
if defined IDflag (
set ID=%ID%%last_num%
set flag=1
goto :eof
)
if /i "%ID:~-1%"=="%last_num%" (
set flag=1
) else set flag=
goto :eof
:Get_Num
:: Extract the value at the corresponding position in %str_wi%
for /l %%i in (1,1,%1) do shift
set wi=%2
goto :eof
:PickUp_Info
set char=%ID:~-2,1%
set /a mod=%char%%%2
if %mod% equ 0 (
set SEX=Female
) else set SEX=Male
for /f "tokens=1*" %%i in ('findstr "%ID:~0,6%" date.txt') do (
set flag=exist
cls
echo.&echo.&echo.&echo.
if defined IDflag (
echo ID card number: %ID_15%
echo.
echo Upgraded number: %ID%
) else echo ID card number: %ID%
echo.
echo Gender: %SEX%
echo.
echo Date of birth: %ID:~6,4% year %ID:~10,2% month %ID:~12,2% day
echo.
echo Place of household registration: %%j
echo.&echo.&echo.&echo.
)
if not "%flag%"=="exist" call :ERR
goto :eof
rem ==== Generate legal number ====
:IDs
for /l %%i in (0,1,999) do (
for %%j in (0 1 2 3 4 5 6 7 8 9 X) do (
set ID=00%%i%%j
call :Check_ID %ID_place%%birthday%!ID:~-4!
if defined flag echo %ID_place%%birthday%!ID:~-4!
)
)
goto :eof
rem ==== Error prompt ====
:ERR
echo.&echo.
echo Illegal number
echo.&echo.&echo.
goto :eof
Last edited by namejm on 2007-3-6 at 10:01 PM ]
附件
1: 数据库及背景知识.rar (2007-3-5 06:52, 26.43 KiB,下载次数: 298)
|

尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。 |
|
2007-3-5 06:47 |
|
|
huzixuan
高级用户
   
积分 537
发帖 219
注册 2006-10-31 来自 芜湖
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
请有想造假证的同志 端正一下自己的想法!
Please have comrades who want to forge false certificates correct their thoughts!
|

江湖远
碧空长
路茫茫
一个人漫无目的的奔跑,风,刺骨的冷.... |
|
2007-3-5 07:03 |
|
|
jmz573515
银牌会员
    
积分 1212
发帖 464
注册 2006-12-13
状态 离线
|
|
2007-3-5 07:30 |
|
|
vkill
金牌会员
     
积分 4103
发帖 1744
注册 2006-1-20 来自 甘肃.临泽
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
能查到详细的地址就好了
It would be nice to be able to find the detailed address.
|
|
2007-3-5 07:46 |
|
|
zh159
金牌会员
     
积分 3687
发帖 1467
注册 2005-8-8
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
Originally posted by vkill at 2007-3-4 18:46:
能查到详细的地址就好了
能查到对方的详细资料、三位数据、相片更好
PS:数据库里没有我旧版的地区号码:4525
Originally posted by vkill at 2007-3-4 18:46:
It would be great if we could find the detailed address.
It would be even better to find the other party's detailed information, three-digit data, and photos.
PS: The database doesn't have my old version of the area code: 4525
|
|
2007-3-5 08:46 |
|
|
slore
铂金会员
      
积分 5212
发帖 2478
注册 2007-2-8
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
每次都要重新检索一边……
第一次的时候就把他们(前6位)存入变量。。。不是速度就提升了?
Every time I have to re-search...
The first time, I stored them (the first 6 digits) into a variable... Isn't the speed improved?
|
|
2007-3-5 09:22 |
|
|
zh159
金牌会员
     
积分 3687
发帖 1467
注册 2005-8-8
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
Originally posted by slore at 2007-3-4 20:22:
每次都要重新检索一边……
第一次的时候就把他们(前6位)存入变量。。。不是速度就提升了?
批处理内变量越多,执行效率越慢
如果存入变量,有4000左右,加载的时间也不少
我试过7000个的,加载后速度慢了好多;用findstr搜索速度很快,我把7000个数据做成文件,findstr几乎马上可以搜索
Originally posted by slore at 2007-3-4 20:22:
Every time you have to re-index...
When you do it for the first time, store them (the first 6 digits) into a variable... Wouldn't that improve the speed?
The more variables in a batch script, the slower the execution efficiency.
If you store them into variables, with about 4000, the loading time is also considerable.
I tried with 7000, and after loading, the speed slowed down a lot; using findstr to search is very fast. I made 7000 data into a file, and findstr can almost search immediately.
|
|
2007-3-5 10:39 |
|
|
328781160
初级用户
 
积分 57
发帖 23
注册 2006-10-29
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
楼主的P处理真是玩到可以登峰造极的境界了!
The楼主's P processing really reaches the realm of being extremely excellent!
|
|
2007-3-5 10:40 |
|
|
ideacm
初级用户
 
积分 20
发帖 9
注册 2007-3-8
状态 离线
|
『第 9 楼』:
使用 LLM 解释/回答一下
因为身份证的编码是有规律的 这个批处理就是利用了这个规律来查和生成或转换的
不可能提详细的信息
法律上也不允许
Because the coding of ID cards has patterns, this batch processing uses this pattern to check, generate, or convert. It is impossible to provide detailed information. It is also not allowed by law.
|
|
2007-3-8 23:26 |
|
|
slore
铂金会员
      
积分 5212
发帖 2478
注册 2007-2-8
状态 离线
|
『第 10 楼』:
使用 LLM 解释/回答一下
Originally posted by zh159 at 2007-3-4 21:39:
批处理内变量越多,执行效率越慢
如果存入变量,有4000左右,加载的时间也不少
我试过7000个的,加载后速度慢了好多;用findstr搜索速度很快,我把7000个数据做成文件,findstr几乎马上可以搜索
那直接一个data文件夹里面是 前6位.txt的文本,文本内容对应的地址^
那么直接type这个速度怎么样呢>
Originally posted by zh159 at 2007-3-4 21:39:
The more variables in a batch script, the slower the execution efficiency.
If stored in variables, with about 4000, the loading time is also considerable.
I tried 7000 ones, and the speed slowed down a lot after loading; findstr searches very quickly. I made 7000 data into a file, and findstr can almost search immediately.
Then directly, in a data folder, there are.txt files with the first 6 digits. The text content corresponds to the address^
Then directly, how is the speed of type this?
|
|
2007-3-9 01:53 |
|
|
nforce1
初级用户
 
积分 128
发帖 16
注册 2007-1-26
状态 离线
|
『第 11 楼』:
使用 LLM 解释/回答一下
namejm 版主厉害啊!!偶试试!
namejm moderator is amazing!! I'll give it a try!
|
|
2007-3-9 09:21 |
|
|
lotus516
高级用户
    论坛上抢劫的
积分 551
发帖 246
注册 2006-9-21
状态 离线
|
|
2007-3-9 11:16 |
|
|
ieutk
初级用户
 
积分 107
发帖 48
注册 2006-11-30
状态 离线
|
『第 13 楼』:
使用 LLM 解释/回答一下
楼主历害啊,服了!
玩P处理到这种境界!
The landlord is amazing, I'm convinced!
Playing P to this level!
|
|
2007-3-9 11:28 |
|
|
xycoordinate
中级用户
  
积分 493
发帖 228
注册 2007-2-16 来自 安徽
状态 离线
|
|
2007-3-9 23:11 |
|
|
tanytxxx
新手上路

积分 16
发帖 14
注册 2006-6-23
状态 离线
|
|
2009-6-21 06:06 |
|