The use of THASHMD5,THASHSHA1,THASHBOBJENKINS,TIDHASHMESSAGEDIGEST5

Source: Internet
Author: User
Tags textout





[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



The use of THASHMD5,THASHSHA1,THASHBOBJENKINS,TIDHASHMESSAGEDIGEST5

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.