程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> Delphi >> url編碼與解碼工具代碼

url編碼與解碼工具代碼

編輯:Delphi
  url編碼與解碼工具代碼,做sql注入分析時會用到
  
  代碼部分:
  
  unit Unit1;
  
  interface
  
  uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, HTTPApp;
  
  type
  TForm1 = class(TForm)
    Button1: TButton;
    Memo1: TMemo;
    Memo2: TMemo;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
    function URLEncode(const msg : String) : String;
    function GetMemoText(memo:TMemo):string;
  public
    { Public declarations }
  end;
  
  var
  Form1: TForm1;
  
  implementation
  
  {$R *.dfm}
  
  procedure TForm1.Button1Click(Sender: TObject);
  var
  i: Integer;
  ss: string;
  begin
  ss := GetMemoText(Memo1);
  Memo1.Text :=ss;
  Memo2.Clear;
  for i := 1 to Length(ss) do
  begin
    Memo2.Text := Memo2.Text + '%' + IntToHex(Ord(ss), 2);
  end;
  end;
  
  function TForm1.URLEncode(const msg: String): String;
  var
    I : Integer;
  begin
    Result := '';
    for I := 1 to Length(msg) do begin
      if msg[I] = ' ' then
          Result := Result + '+'
      else if msg[I] in ['a'..'z', 'A'..'Z', '0'..'9'] then
          Result := Result + msg[I]
      else
          Result := Result + '%' + IntToHex(ord(msg[I]), 2);
    end;
  
  end;
  
  procedure TForm1.Button2Click(Sender: TObject);
  var ss:string;
  begin
  Memo2.Clear;
  ss :=GetMemoText(Memo1);
  Memo1.Text :=ss;
  Memo2.Text :=HTTPDecode(trim(ss));
  end;
  
  function TForm1.GetMemoText(memo: TMemo): string;
  var i:integer;
  begin
  for i:=0 to memo.Lines.Count-1 do
  begin
    Result :=Result + trim(memo.Lines);
  end;
  end;
  
  end.
  url編碼與解碼工具附代碼
  
  
  url編碼與解碼工具附代碼,代碼很簡單,做sql注入分析時經常用到,但一時又找不到,就寫了一個
  
  
  代碼部分:
  
  unit Unit1;
  
  interface
  
  uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, HTTPApp;
  
  type
  TForm1 = class(TForm)
    Button1: TButton;
    Memo1: TMemo;
    Memo2: TMemo;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
    function URLEncode(const msg : String) : String;
    function GetMemoText(memo:TMemo):string;
  public
    { Public declarations }
  end;
  
  var
  Form1: TForm1;
  
  implementation
  
  {$R *.dfm}
  
  procedure TForm1.Button1Click(Sender: TObject);
  var
  i: Integer;
  ss: string;
  begin
  ss := GetMemoText(Memo1);
  Memo1.Text :=ss;
  Memo2.Clear;
  for i := 1 to Length(ss) do
  begin
    Memo2.Text := Memo2.Text + '%' + IntToHex(Ord(ss), 2);
  end;
  end;
  
  function TForm1.URLEncode(const msg: String): String;
  var
    I : Integer;
  begin
    Result := '';
    for I := 1 to Length(msg) do begin
      if msg[I] = ' ' then
          Result := Result + '+'
      else if msg[I] in ['a'..'z', 'A'..'Z', '0'..'9'] then
          Result := Result + msg[I]
      else
          Result := Result + '%' + IntToHex(ord(msg[I]), 2);
    end;
  
  end;
  
  procedure TForm1.Button2Click(Sender: TObject);
  var ss:string;
  begin
  Memo2.Clear;
  ss :=GetMemoText(Memo1);
  Memo1.Text :=ss;
  Memo2.Text :=HTTPDecode(trim(ss));
  end;
  
  function TForm1.GetMemoText(memo: TMemo): string;
  var i:integer;
  begin
  for i:=0 to memo.Lines.Count-1 do
  begin
    Result :=Result + trim(memo.Lines);
  end;
  end;
  
  end.
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved