本文整理自网络,侵删。
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 xe filesizebyname 要引用哪些文件
Delphi10.3构造一个json数据的第三种方法,并格式化输出
Delphi的unicode与gb2312转转换,汉字unicode转gb2312
更多相关阅读请进入《Delphi》频道 >>