delphi中MD5的获取(Indy 10)
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs , IdHashMessageDigest, StdCtrls;
type
TMD5 = class(TIdHashMessageDigest5);
TForm2 = class(TForm)
Memo1: TMemo;
Button1: TButton;
Memo2: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject);
var
MyMD5: TMD5;
begin
MyMD5 := TMD5.Create;
try
Memo2.Text := MyMD5.HashStringAsHex(Memo1.Text); // Indy10中可以直接HashStringAsHex
finally
MyMD5.Free;
end;
end;
end.
以上方法只适合 Indy10
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs , IdHashMessageDigest, StdCtrls;
type
TMD5 = class(TIdHashMessageDigest5);
TForm2 = class(TForm)
Memo1: TMemo;
Button1: TButton;
Memo2: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject);
var
MyMD5: TMD5;
begin
MyMD5 := TMD5.Create;
try
Memo2.Text := MyMD5.HashStringAsHex(Memo1.Text); // Indy10中可以直接HashStringAsHex
finally
MyMD5.Free;
end;
end;
end.
以上方法只适合 Indy10