校驗算法與ASP程序
∑(ai×Wi)(mod 11)
i: 表示號碼字符從由至左包括校驗碼在內(nèi)的位置序號;
ai 表示第i位置上的號碼字符值;
Wi 第i位置上的加權(quán)因子,其數(shù)值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
相應(yīng)的校驗碼:
∑(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
下面是校驗函數(shù):
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
其它校驗:
性別與出生年月:
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
關(guān)于戶籍判斷則而要數(shù)據(jù)庫.這里就不提供了.
相關(guān)文章
ASP開發(fā)中數(shù)據(jù)庫文件調(diào)用的捷徑
本文針對ASP程序設(shè)計中最基礎(chǔ)、也是最關(guān)鍵的部分"數(shù)據(jù)庫文件的調(diào)用"進行說明,同時談?wù)凙SP程序設(shè)計中數(shù)據(jù)庫文件調(diào)用的一些技巧2006-09-09A利用ASP小偷和Google實現(xiàn)在線翻譯功能的代碼
A利用ASP小偷和Google實現(xiàn)在線翻譯功能的代碼...2007-11-11access數(shù)據(jù)庫的一些少用操作,ASP,創(chuàng)建數(shù)據(jù)庫文件,創(chuàng)建表,創(chuàng)建字段,ADOX
access數(shù)據(jù)庫的一些少用操作,ASP,創(chuàng)建數(shù)據(jù)庫文件,創(chuàng)建表,創(chuàng)建字段,ADOX...2006-10-10