yuleiangel 发表于 2009-4-29 16:33:45

字符串隐藏一法

作者:fonge
日期:2007-8-2 09:58
{**************************************************************

code by fonge with almost pure delphi
                                                         2007-08-02
设计模式:
通过使用char数组来实现字符串隐藏;

具体请看示例代码:
==================================================
源码如下:复制内容到剪贴板代码:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
private
    { Private declarations }
public
    { Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
t:array of char;   //用数组来实现隐藏
begin
t:=Char(103);
t:=Char(111);
t:=Char(111);
t:=Char(100);
t:=Char(32);
t:=Char(106);
t:=Char(111);
t:=Char(98);
t:=Char(44);
t:=Char(32);
t:=Char(109);
t:=Char(97);
t:=Char(110);
t:=Char(33);
Showmessage(t);               //英文的“good job, man!”
end;

procedure TForm1.Button2Click(Sender: TObject);
var
t:array of char;          //用数组来实现隐藏
begin
t:=Char(185);
t:=Char(167);
t:=Char(207);
t:=Char(178);
t:=Char(196);
t:=Char(227);
t:=Char(163);
t:=Char(172);
t:=Char(215);
t:=Char(162);
t:=Char(178);
t:=Char(225);
t:=Char(179);
t:=Char(201);
t:=Char(185);
t:=Char(166);
t:=Char(193);
t:=Char(203);
t:=Char(163);
t:=Char(161);
Showmessage(t);                     //中文的“恭喜你,注册成功了!”
end;

end.有人会觉得这样写代码很累,没关系,这里有批量生成上面结果的代码,我正用之...
且上面代码均为其生成之...
edit1.text输入你的提示字符串,edit2.text输入为你预定义的变量名,默认为't'...
点击即可生成像上面的代码,保存在ByTeCrypt.txt,直接copy使用之...复制内容到剪贴板代码:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
    Button1: TButton;
    Edit1: TEdit;
    Edit2: TEdit;
    Label1: TLabel;
    GroupBox1: TGroupBox;
    Label2: TLabel;
    Label3: TLabel;
    procedure Button1Click(Sender: TObject);
private
    { Private declarations }
public
    { Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
    wFile:TextFile;
    wFileName,s,t:String;
    i:Integer;
begin
    s:=Edit1.Text;
    t:=Edit2.Text;
    if length(s)=0 then
      begin
         showmessage('Please input your string');
         exit;
      end;
    if length(t)=0 then
      begin
         showmessage('请输入变量名');
         exit;
      end;
    t:=Edit2.Text;
    wFileName:= 'ByTeCrypt.txt';
    AssignFile(wFile, wFileName);
    Rewrite(wFile);
    Writeln(wFile,'var');
    Writeln(wFile,''+t+':array of char;');                  //生成定义t:array of char
    Writeln(wFile,'begin');
    for i:=1 to Length(s) do
       begin
          Writeln(wFile, ''+t+'['+IntToStr(i)+']:=Char('+IntToStr(Ord(s))+');');   //生成语句t[?]:=Char(?);
       end;
    Writeln(wFile,'Showmessage('+t+');');
    Writeln(wFile,'end;');
    CloseFile(wFile);
    showmessage('执行完毕,请查看同目录下ByTeCrypt.txt文件!');
end;
end.

game168 发表于 2009-6-11 19:39:16

这方面值得参考一下,哈哈。
页: [1]
查看完整版本: 字符串隐藏一法