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 将label的caption内容竖向显示

Delphi 通过u盘方式加密

Delphi获取系统特殊文件夹路径

Delphi 反转字符串方法2

Delphi get_hd_serial() 获得磁盘驱动器序列号

Delphi 去除 tstringlist 重复项

Delphi firedac 获取 insert 记录的自增 id

Delphi字符串、数组操作函数

Delphi xe10 创建匿名线程

Delphi中messagebox的用法

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



打赏

取消

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

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

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

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

评论

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