去官方文档搜就行了,引入System.Hash 单元:
http://docwiki.embarcadero.com/Libraries/Athens/en/System.Hash.THashMD5
-----------------------------------------------------------------------------------------------
unit Unit4;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, System.Hash, System.NetEncoding;
type
TForm4 = class(TForm)
edt1: TEdit;
btn1: TButton;
edt2: TEdit;
lbl1: TLabel;
lbl2: TLabel;
lbl3: TLabel;
procedure btn1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form4: TForm4;
implementation
{$R *.dfm}
procedure TForm4.btn1Click(Sender: TObject);
begin
//THashMD5 是个记录,GetHashString是个类方法,所以可以这样直接使用,不用创建和释放
edt2.Text := THashMD5.GetHashString(Trim(edt1.Text));
end;
procedure TForm4.FormCreate(Sender: TObject);
begin
ReportMemoryLeaksOnShutdown := true;
end;
end.