procedure SeqEnc(var Str:String;Key:Integer;Times:Integer); var i,c,n:Integer; Key1,Key2,Key3,Key4:Byte; begin n:=Length(Str); if n=0 then exit; Key4:=Byte(Key shr 24); Key3:=Byte(Key shr 16); Key2:=Byte(Key shr 8); Key1:=Byte(Key); for c:=Times-1 downto 0 do begin Str[1]:=Char(Byte(Str[1])+Key3); for i:=2 to n do Str[i]:=Char((Byte(Str[i-1])+Byte(Str[i])) xor Key1); Str[n]:=Char(Byte(Str[n])+Key4); for i:=n-1 downto 1 do Str[i]:=Char((Byte(Str[i+1])+Byte(Str[i])) xor Key2); end; end; procedure SeqDec(var Str:String;Key:Integer;Times:Integer); var i,c,n:Integer; Key1,Key2,Key3,Key4:Byte; begin n:=Length(Str); if n=0 then exit; Key4:=Byte(Key shr 24); Key3:=Byte(Key shr 16); Key2:=Byte(Key shr 8); Key1:=Byte(Key); for c:=Times-1 downto 0 do begin for i:=1 to n-1 do Str[i]:=Char(Byte(Str[i]) xor Key2-Byte(Str[i+1])); Str[n]:=Char(Byte(Str[n])-Key4); for i:=n downto 2 do Str[i]:=Char(Byte(Str[i]) xor Key1-Byte(Str[i-1])); Str[1]:=Char(Byte(Str[1])-Key3); end; end;我想对一些数字进行加密和解密,我只想知道怎样可以把数字输进去,然后出结果谢谢!
SeqEnc(var Str:String;Key:Integer;Times:Integer);调用的时候,你就SeqEnc('12345',1,2); 也可以 var s : string; tKey ,tTimes : integer;//变量的定义,用于传输指定数值到过程 begin s := '1234'; tKey := 1; tTimes := 2; seqEnc(s,tKey,tTimes);//调用过程 end;
我现在有DELPHI 10 LITE 希望能够告诉我一下步骤因为我什么也不会 我都不知道应当建立什么文件,以及如何执行出结果汗
unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TForm1 = class(TForm) Edit1: TEdit; Edit2: TEdit; Button1: TButton; Button2: TButton; Edit3: TEdit; Label1: TLabel; Label2: TLabel; Label3: TLabel; Label4: TLabel; Edit4: TEdit; procedure Button1Click(Sender: TObject); procedure SeqDec(var Str:String;Key:Integer;Times:Integer); procedure SeqEnc(var Str:String;Key:Integer;Times:Integer); procedure Button2Click(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}procedure TForm1.SeqEnc(var Str:String;Key:Integer;Times:Integer); var i,c,n:Integer; Key1,Key2,Key3,Key4:Byte; begin n:=Length(Str); if n=0 then exit; Key4:=Byte(Key shr 24); Key3:=Byte(Key shr 16); Key2:=Byte(Key shr 8); Key1:=Byte(Key); for c:=Times-1 downto 0 do begin Str[1]:=Char(Byte(Str[1])+Key3); for i:=2 to n do Str[i]:=Char((Byte(Str[i-1])+Byte(Str[i])) xor Key1); Str[n]:=Char(Byte(Str[n])+Key4); for i:=n-1 downto 1 do Str[i]:=Char((Byte(Str[i+1])+Byte(Str[i])) xor Key2); end; end;procedure TForm1.SeqDec(var Str:String;Key:Integer;Times:Integer); var i,c,n:Integer; Key1,Key2,Key3,Key4:Byte; begin n:=Length(Str); if n=0 then exit; Key4:=Byte(Key shr 24); Key3:=Byte(Key shr 16); Key2:=Byte(Key shr 8); Key1:=Byte(Key); for c:=Times-1 downto 0 do begin for i:=1 to n-1 do Str[i]:=Char(Byte(Str[i]) xor Key2-Byte(Str[i+1])); Str[n]:=Char(Byte(Str[n])-Key4); for i:=n downto 2 do Str[i]:=Char(Byte(Str[i]) xor Key1-Byte(Str[i-1])); Str[1]:=Char(Byte(Str[1])-Key3); end; end;procedure TForm1.Button1Click(Sender: TObject); var s:string; begin s:=Edit1.Text; SeqEnc(s,StrToInt(Edit2.Text),StrToInt(Edit3.Text)); Edit4.Text:=s; end;procedure TForm1.Button2Click(Sender: TObject); var s:string; begin s:=Edit1.Text; SeqDec(s,StrToInt(Edit2.Text),StrToInt(Edit3.Text)); Edit4.Text:=s; end; end.
:)
var
i,c,n:Integer;
Key1,Key2,Key3,Key4:Byte;
begin
n:=Length(Str);
if n=0 then
exit;
Key4:=Byte(Key shr 24);
Key3:=Byte(Key shr 16);
Key2:=Byte(Key shr 8);
Key1:=Byte(Key);
for c:=Times-1 downto 0 do
begin
Str[1]:=Char(Byte(Str[1])+Key3);
for i:=2 to n do
Str[i]:=Char((Byte(Str[i-1])+Byte(Str[i])) xor Key1);
Str[n]:=Char(Byte(Str[n])+Key4);
for i:=n-1 downto 1 do
Str[i]:=Char((Byte(Str[i+1])+Byte(Str[i])) xor Key2);
end;
end;
procedure SeqDec(var Str:String;Key:Integer;Times:Integer);
var
i,c,n:Integer;
Key1,Key2,Key3,Key4:Byte;
begin
n:=Length(Str);
if n=0 then
exit;
Key4:=Byte(Key shr 24);
Key3:=Byte(Key shr 16);
Key2:=Byte(Key shr 8);
Key1:=Byte(Key);
for c:=Times-1 downto 0 do
begin
for i:=1 to n-1 do
Str[i]:=Char(Byte(Str[i]) xor Key2-Byte(Str[i+1]));
Str[n]:=Char(Byte(Str[n])-Key4);
for i:=n downto 2 do
Str[i]:=Char(Byte(Str[i]) xor Key1-Byte(Str[i-1]));
Str[1]:=Char(Byte(Str[1])-Key3);
end;
end;我想对一些数字进行加密和解密,我只想知道怎样可以把数字输进去,然后出结果谢谢!
也可以
var
s : string;
tKey ,tTimes : integer;//变量的定义,用于传输指定数值到过程
begin
s := '1234';
tKey := 1;
tTimes := 2;
seqEnc(s,tKey,tTimes);//调用过程
end;
希望能够告诉我一下步骤因为我什么也不会
我都不知道应当建立什么文件,以及如何执行出结果汗
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
Button2: TButton;
Edit3: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Edit4: TEdit;
procedure Button1Click(Sender: TObject);
procedure SeqDec(var Str:String;Key:Integer;Times:Integer);
procedure SeqEnc(var Str:String;Key:Integer;Times:Integer);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.SeqEnc(var Str:String;Key:Integer;Times:Integer);
var
i,c,n:Integer;
Key1,Key2,Key3,Key4:Byte;
begin
n:=Length(Str);
if n=0 then
exit;
Key4:=Byte(Key shr 24);
Key3:=Byte(Key shr 16);
Key2:=Byte(Key shr 8);
Key1:=Byte(Key);
for c:=Times-1 downto 0 do
begin
Str[1]:=Char(Byte(Str[1])+Key3);
for i:=2 to n do
Str[i]:=Char((Byte(Str[i-1])+Byte(Str[i])) xor Key1);
Str[n]:=Char(Byte(Str[n])+Key4);
for i:=n-1 downto 1 do
Str[i]:=Char((Byte(Str[i+1])+Byte(Str[i])) xor Key2);
end;
end;procedure TForm1.SeqDec(var Str:String;Key:Integer;Times:Integer);
var
i,c,n:Integer;
Key1,Key2,Key3,Key4:Byte;
begin
n:=Length(Str);
if n=0 then
exit;
Key4:=Byte(Key shr 24);
Key3:=Byte(Key shr 16);
Key2:=Byte(Key shr 8);
Key1:=Byte(Key);
for c:=Times-1 downto 0 do
begin
for i:=1 to n-1 do
Str[i]:=Char(Byte(Str[i]) xor Key2-Byte(Str[i+1]));
Str[n]:=Char(Byte(Str[n])-Key4);
for i:=n downto 2 do
Str[i]:=Char(Byte(Str[i]) xor Key1-Byte(Str[i-1]));
Str[1]:=Char(Byte(Str[1])-Key3);
end;
end;procedure TForm1.Button1Click(Sender: TObject);
var s:string;
begin
s:=Edit1.Text;
SeqEnc(s,StrToInt(Edit2.Text),StrToInt(Edit3.Text));
Edit4.Text:=s;
end;procedure TForm1.Button2Click(Sender: TObject);
var s:string;
begin
s:=Edit1.Text;
SeqDec(s,StrToInt(Edit2.Text),StrToInt(Edit3.Text));
Edit4.Text:=s;
end;
end.