delphi身份证验证
来源:互联网 发布:bim施工现场布置软件 编辑:程序博客网 时间:2024/05/18 03:14
uses DateUtils;
const
IntMultiplication: Array[1..17] Of Integer=(7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2);
//函数名:IsRightID
//参数:sID,身份证号码 (输入)//返回值:sID是标准身份证号,返回OK,否则返回相应信息
function IsRightID(sID:string):Boolean;
//判断是否存在非法字符
function JudgeIllegal(str:string):Boolean;
var
i:Integer;
begin
Result:=False;
for i := 1 to Length(str) do
begin
case str[i] of '0'..'9':
begin
end
else
begin
Exit;
end;
end;
end;
Result := True;
end;
//加权函数
function Weighted(str:string):string;
var
i:Integer;
sum:Integer;
begin
sum:=0;
for i:=1 to 17 do
begin
sum:=sum+StrToInt(str[i])*IntMultiplication[i];
end;
sum:=sum mod 11;
case sum of
0 : Result:='1';
1 : Result:='0';
2 : Result:='X';
3 : Result:='9';
4 : Result:='8';
5 : Result:='7';
6 : Result:='6';
7 : Result:='5';
8 : Result:='4';
9 : Result:='3';
10: Result:='2';
end;
end;
begin
Result:=False;
try
if Length(sID)<>18 then
begin
ShowMessage('身份证号应为18位!');
exit;
end;
if not JudgeIllegal(Copy(sID,1,17)) then
begin
ShowMessage('身份证号前17位应为数字!');
exit;
end;
//判断成功
if (Weighted(sID)=Copy(sID,18,1)) then
begin
end
else
begin
ShowMessage('身份证号码有误!');
Exit;
end
except
on e:Exception do
begin
ShowMessage('异常:'+e.Message);
Exit;
end;
end;
Result := True;
end;
0 0
- delphi身份证验证函数
- delphi身份证验证
- delphi身份证验证
- 身份证验证
- 身份证验证
- 身份证验证
- 身份证验证
- 身份证验证
- 验证身份证
- 身份证验证
- 身份证验证
- 身份证验证
- 身份证验证
- 身份证验证
- 身份证验证
- 身份证验证
- 身份证验证
- 验证身份证
- ASPXGridView 数据分页设置
- C#实现精确计时,精度1ms
- 在windows 下用 vs2010 开发第一个vlc程序
- GRE写作评分标准
- getComputedStyle、currentStyle的区别与用法
- delphi身份证验证
- 体验更低功耗的开源硬件平台-迅为4412开发板
- 让android的TextView可以滚动
- POJ 3617 Best Cow Line
- js高级编程-Bom
- Xcode6中进行Objective-C现代化的工具
- boost 1.51.0 在MAC系统上编译Android序列化静态库
- NSString [a compare:b] NSOrderedSame NSOrderedAscending NSOrderedDescending
- 我的第一个HTML5应用