代码:
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[1..'+IntToStr(Length(s))+'] of char;'); //生成定义t:array[1..?] of char
Writeln(wFile,'begin');
for i:=1 to Length(s) do
begin
Writeln(wFile, ' '+t+'['+IntToStr(i)+']:=Char('+IntToStr(Ord(s[i]))+');'); //生成语句t[?]:=Char(?);
end;
Writeln(wFile,' Showmessage('+t+');');
Writeln(wFile,'end;');
CloseFile(wFile);
showmessage('执行完毕,请查看同目录下ByTeCrypt.txt文件!');
end;
end.
上一页12下一页