Delphi实现身份证号码15到18位升位算法


本文整理自网络,侵删。

 身份证号码15到18位升位算法Delphi实现

function GetNewID(ID: string): string;
const
W: array[1..18] of Integer = (7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2, 1);
A: array[0..10] of Char = ('1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2');
var
i, j, S: integer;
NewID: string;
begin
if Length(ID) <> 15 then
result := ''
else
begin
NewID := ID;
Insert('19', NewID, 7);
S := 0;
try
for i := 1 to 17 do
begin
j := StrToInt(NewID[i]) * W[i];
S := S + j;
end;
except
result := '';
exit;
end;
S := S mod 11;
Result := NewID + A[S];
end;
end;

相关阅读 >>

Delphi中使用 twebbrowser 编辑网页

Delphi 2009 之 tcategorypanelgroup[4]: height

Delphi中判断窗体最大化和最小化事件

Delphi 反转内存的函数

Delphi firedac sqlite不能插入"&"符号

Delphi xe10 文件目录/路径操作 (andorid、ios、windows)

Delphi mscomm 发送接收

Delphi隐藏指定程序的托盘图标

Delphi 解决idtcpclient和idtcpserver通信中文乱码问题

Delphi研究之驱动开发篇(六)--利用section与用户模式程

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...