[delphi] view plain copy
- unit Unit1;
- interface
- uses
- Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
- System.Classes, Vcl.Graphics,Soap.EncdDecd,IdHashMessageDigest,IdSSLOpenSSL,IdSSLOpenSSLHeaders,
- Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, System.Hash;
- type
- TForm1 = class(TForm)
- Button1: TButton;
- Button2: TButton;
- Button3: TButton;
- Button4: TButton;
- procedure Button1Click(Sender: TObject);
- procedure Button2Click(Sender: TObject);
- procedure Button3Click(Sender: TObject);
- procedure Button4Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- TMD5 = class(TIdHashMessageDigest5);
- var
- Form1: TForm1;
- implementation
- {$R *.dfm}
- function MyFun(p: Pointer): Integer; stdcall;
- var
- i: Integer;
- begin
- for i := 0 to 500 do
- begin
- Form1.Canvas.Lock;
- Form1.Canvas.TextOut(10, 10, 'threadid=' + IntToStr(GetCurrentThreadId()) +
- ',' + IntToStr(i));
- Form1.Canvas.Unlock;
- Sleep(10);
- end;
- Result := 0;
- end;
- procedure MyPro();
- var
- i: Integer;
- begin
- for i := 0 to 500 do
- begin
- Form1.Canvas.Lock;
- Form1.Canvas.TextOut(10, 10, 'threadid=' + IntToStr(GetCurrentThreadId()) +
- ',' + IntToStr(i));
- Form1.Canvas.Unlock;
- Sleep(10);
- end;
- end;
- procedure TForm1.Button1Click(Sender: TObject);
- begin
- ShowMessage('xxx');
- MessageBox(0, 'nn', 'mmm', 0);
- Application.MessageBox('xxx', 'system', 0);
- end;
- procedure TForm1.Button2Click(Sender: TObject);
- begin
- //
- TThread.CreateAnonymousThread(MyPro).Start;
- end;
- procedure TForm1.Button3Click(Sender: TObject);
- var
- data, key: string;
- begin
- data := 'xxx';
- key := 'key';
- ShowMessage(THashMD5.Create.GetHashString(data));
- ShowMessage(THashMD5.Create.GetHMAC(data, key));
- ShowMessage(THashSHA1.Create.GetHashString(data));
- ShowMessage(THashSHA1.Create.GetHMAC(data, key));
- ShowMessage(THashBobJenkins.Create.GetHashString(data));
- ShowMessage(THash.GetRandomString(10));
- ShowMessage(THash.DigestAsString(TEncoding.UTF8.GetBytes(data)));
- end;
- procedure TForm1.Button4Click(Sender: TObject);
- var
- data, key: string;
- begin
- data:='fuck';
- data:=EncodeString(data) ;
- ShowMessage(data);
- ShowMessage(DecodeString(data));
- ShowMessage(TMD5.Create.HashStringAsHex(data));
- end;
- end.
http://blog.csdn.net/earbao/article/details/46532077