delphi md5加密字符串


本文整理自网络,侵删。

 unit ToMd5;

interface
uses
IdHashMessageDigest, IdHash, IdGlobal;

type
TMD5 = class(TIdHashMessageDigest5);

function StrToMD5(S: String): String; overload;
function StrToMD516(S: String; L: integer): String; overload; //返加16位MD5值
function StrToMD532(S: String; L: integer): String; overload; //返回32位MD5值

implementation
function StrToMD5(S: String): String;
var
Md5Encode: TMD5;
begin
Md5Encode:= TMD5.Create;
result:= Md5Encode.AsHex(Md5Encode.HashValue(S));
Md5Encode.Free;
end;

function StrToMD516(S: String; L: integer): String;
begin
result:= copy(StrToMD5(S),9,L);
end;

function StrToMD532(S: String; L: integer): String; overload;
begin
result:= copy(StrToMD5(S),1,L);
end;
end.

相关阅读 >>

Delphi winapi: writeprivateprofilestring、getprivateprofilestring - 简单读写 ini 文件

Delphi 极速字符串替换函数

Delphi与汇编杂谈

Delphi yearof 根据指定的日期返回年

Delphi 10.4 自定义托管记录

Delphi将image存入mysql数据库

Delphi checklistbox 用法

Delphi中怎么取出字符串中单个char

Delphi listview导出到excel

Delphi下程序内存泄露报告

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



打赏

取消

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

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

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

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

评论

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