delphi md5加密字符串  
官方Delphi 学习QQ群: 682628230(三千人)
频道

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.

推荐分享
图文皆来源于网络,内容仅做公益性分享,版权归原作者所有,如有侵权请告知删除!
 

Copyright © 2014 DelphiW.com 开发 源码 文档 技巧 All Rights Reserved
晋ICP备14006235号-8 晋公网安备 14108102000087号

执行时间: 0.036164999008179 seconds