当前位置: 首页 > 图文教程 > 网络编程 > ASP > 身份证校验算法与ASP程序

ASP
冒泡算法的三种JavaScript表示
asp无限分级(递归调用)
VBS、ASP代码语法加亮显示的类
安全脚本程序的编写 V1.0
atom2rss.asp
atom_js.asp
google sitemap.asp
用ASP读取/写入UTF-8编码格式的文件
捌度空间 缓存类
再来个专门为google量身定做的sitemap生成代码,(可是动态的哦)
一个能对访问者进行编号、记录访问次数、IP、时间的统计制作实例
如何在ASP页面动态Inclue文件?
多域名一网站时如果返回最原来的域名
网页木马代码例子(里面的文件是漏洞扫描器,呵呵)
ASP万用分页程序
ASP项目中的公共翻页模块
在ASP中使用均速分页法提高分页速度
3种不同的方法生成文件
身份证校验算法与ASP程序
ASP抽取数据的执行效率

身份证校验算法与ASP程序


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-13   浏览: 25 ::
收藏到网摘: n/a

18位身份证校验算法
身份证校验码算法
身份证校验码产生方法:
∑(ai×Wi)(mod 11)
i: 表示号码字符从由至左包括校验码在内的位置序号;
ai 表示第i位置上的号码字符值;
Wi 第i位置上的加权因子,其数值Wi=mod(power(2,(n-1)),11)
i 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
Wi 7 9 10 5 8 4 2 1 6 3 7 9 10 5 8 4 2 1
相应的校验码:
∑(ai×WI)(mod 11) 0 1 2 3 4 5 6 7 8 9 10
校验码字符值ai 1 0 X 9 8 7 6 5 4 3 2
下面是校验函数:
FUNCTION sfzjy(num)
if len(num)=15 then
cID = left(num,6)&"19"&right(num,9)
elseif len(num)=17 or len(num)=18 then
cID = left(num,17)
end if
nSum=mid(cID,1,1) * 7
nSum=nsum+mid(cID,2,1) * 9
nSum=nsum+mid(cID,3,1) * 10
nSum=nsum+mid(cID,4,1) * 5
nSum=nsum+mid(cID,5,1) * 8
nSum=nsum+mid(cID,6,1) * 4
nSum=nsum+mid(cID,7,1) * 2
nSum=nsum+mid(cID,8,1) * 1
nSum=nsum+mid(cID,9,1) * 6
nSum=nsum+mid(cID,10,1) * 3
nSum=nsum+mid(cID,11,1) * 7
nSum=nsum+mid(cID,12,1) * 9
nSum=nsum+mid(cID,13,1) * 10
nSum=nsum+mid(cID,14,1) * 5
nSum=nsum+mid(cID,15,1) * 8
nSum=nsum+mid(cID,16,1) * 4
nSum=nsum+mid(cID,17,1) * 2
'*计算校验位
check_number=12-nsum mod 11
If check_number=10 then check_number="X" elseIf check_number=12 then check_number="1" elseif check_number=11 then check_number="0" End if sfzjy=check_number
End function

其它校验:
性别与出生年月:
sfznum=身份证号码
lenx=len(sfznum)
if lenx=15 then
yy="19"&mid(xian,7,2)
mm=mid(xian,9,2)
dd=mid(xian,11,2)
aa=mid(xian,15,1) '15位身分证取第十五位,能被2整除为女性
end if
if lenx=18 then
yy=mid(xian,7,4)
mm=mid(xian,11,2)
dd=mid(xian,13,2)
aa=mid(xian,17,1) '18位身分证取第十七位,能被2整除为女性
end if
if aa mod 2=0 then
xb="女"
else
xb="男"
end if
if lenx=18 then
if mid(xian,18,1)<>cstr(sfzjy(xian)) then '如果第十八位校验码不等于计算出的校验码则身份证号码有误.
response.write "提示:身份证校验位错误!"
else
response.write "结果:身份证号码校验为合法号码!"
end if
else '如果输入的是十五位号,则计算出十八位新号
response.write "新身份证:"&left(xian,6)&"19"&right(xian,9)&cstr(sfzjy(xian))
end if
关于户籍判断则而要数据库.这里就不提供了.