本文整理自网络,侵删。
unit Umain;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls,IdHashMessageDigest,IdGlobal,IdHash;
type TForm1 = class(TForm) Button1: TButton; OpenDialog1: TOpenDialog; Memo1: TMemo; procedure Button1Click(Sender: TObject); private function StreamToMD5(s:TFileStream):string; { Private declarations }
public { Public declarations } end;
type TMD5=class(TIdHashMessageDigest5);
var Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);var filesen:TFileStream; str:string;begin if opendialog1.Execute then begin filesen:=TFileStream.Create(opendialog1.FileName,fmopenread or fmshareExclusive); str:=StreamToMD5(filesen); memo1.Lines.Add(str); filesen.Free; end;end;
function TForm1.StreamToMD5(s:TFileStream):string;var MD5Encode:TMD5; long:T4x4LongWordRecord;begin MD5Encode:=TMD5.Create; try long:=md5encode.HashValue(s); result:=MD5Encode.AsHex(long); finally MD5Encode.Free; end;end;
end.――――――――――――――――
原文链接:https://blog.csdn.net/xxkku521/article/details/8815142
相关阅读 >>
Delphi的字符截取函数leftstr,midstr,rightstr的介绍以及字符串拆分
Delphi webservice 中采用 tsoapattachment 传输文件
Delphi通过spcomm com口发短信包括pud编码解码
Delphi 判断字符是否是汉字,bytetype字符串中判断是否英文
更多相关阅读请进入《Delphi》频道 >>