第一个: procedure TForm1.Button1Click(Sender: TObject); var s, s1: String; begin s:='中'; s1:=''; For i:=1 to Length(s) do begin s1:=s1+chr(ord(s[length-i+1]) xor $d6); end; For i:=1 to Length(s1) do begin s1[i]:=chr(ord(s1[i]) xor $8c); end; end;
procedure TForm1.Button1Click(Sender: TObject); var s, s1: String; i: Integer; begin s:='中'; s1:=''; For i:=1 to Length(s) do begin s1:=s1+chr(ord(s[length-i+1]) xor $8c); end; For i:=1 to Length(s1) do begin s1[i]:=chr(ord(s1[i]) xor $d6); end; end; 这是第二个,没有测试
http://kingron.myetang.com/zsfunc0q.htm 上不去呀
这次测试过了,可以。 procedure TForm1.Button1Click(Sender: TObject); var s, s1: String; i: Integer; begin s:='中华人民共各国'; s1:=''; For i:=1 to Length(s) do begin s1:=s1+chr(ord(s[length(s)-i+1]) xor $8c); end; For i:=1 to Length(s1) do begin s1[i]:=chr(ord(s1[i]) xor $d6); end; ShowMessage(S1); s:=S1; s1:=''; For i:=1 to Length(s) do begin s1:=s1+chr(ord(s[length(s)-i+1]) xor $d6); end; For i:=1 to Length(s1) do begin s1[i]:=chr(ord(s1[i]) xor $8c); end; ShowMessage(S1); end;
这次测试过了,可以。 procedure TForm1.Button1Click(Sender: TObject); var s, s1: String; i: Integer; begin s:='中华人民共各国'; s1:=''; For i:=1 to Length(s) do begin s1:=s1+chr(ord(s[length(s)-i+1]) xor $8c); end; For i:=1 to Length(s1) do begin s1[i]:=chr(ord(s1[i]) xor $d6); end; ShowMessage(S1); s:=S1; s1:=''; For i:=1 to Length(s) do begin s1:=s1+chr(ord(s[length(s)-i+1]) xor $d6); end; For i:=1 to Length(s1) do begin s1[i]:=chr(ord(s1[i]) xor $8c); end; ShowMessage(S1); end;
这次测试过了,可以。 procedure TForm1.Button1Click(Sender: TObject); var s, s1: String; i: Integer; begin s:='中华人民共各国'; s1:=''; For i:=1 to Length(s) do begin s1:=s1+chr(ord(s[length(s)-i+1]) xor $8c); end; For i:=1 to Length(s1) do begin s1[i]:=chr(ord(s1[i]) xor $d6); end; ShowMessage(S1); s:=S1; s1:=''; For i:=1 to Length(s) do begin s1:=s1+chr(ord(s[length(s)-i+1]) xor $d6); end; For i:=1 to Length(s1) do begin s1[i]:=chr(ord(s1[i]) xor $8c); end; ShowMessage(S1); end;
刚帮你调通 procedure TForm1.Button1Click(Sender: TObject); var S:PChar; begin GetMem(S,4); Form1.JiaMi('123',3,S); ShowMessagE(StrPAs(S)); end;procedure TForm1.JiaMi(StrP: PChar; StrL: Integer; StrR: PChar); var P1:PChar; var P2:PChar; var i:integer; var C:Char; var K:Char; begin P1:=StrP; P2:=StrR; For i:=1 to StrL do begin C:=P1^; C:=Chr(Ord(C) xor $d6); P2^:=C; inc(P1); inc(P2); end; dec(P2); P1:=StrR; While(P2>P1) do begin C:=P2^; K:=P1^; P2^:=K; P1^:=C; inc(P1); dec(P2); end; P1:=StrR; P2:=StrR; For i:=1 to StrL do begin C:=P1^; C:=Chr(Ord(C) xor $8c); P2^:=C; inc(P1); inc(P2); end; end; 你在一或一叹就回来了,所以加密接密一样的程序 procedure TForm1.Button2Click(Sender: TObject); var c:char; begin c:='9'; c:=chr(ord(c) xor $d6); c:=chr(ord(c) xor $d6); showMessagE(c); end;
(*// 标题:字符串加密;pascal字符表示 说明:应用于文件加密 设计:Zswang 日期:2002-02-19 支持:[email protected] //*)///////Begin Source function StringToDisplay(mString: string): string; var I: Integer; S: string; begin Result := ''; S := ''; for I := 1 to Length(mString) do if mString[I] in [#32..#127] then S := S + mString[I] else begin if S <> '' then begin Result := Result + QuotedStr(S); S := ''; end; Result := Result + Format('#$%x', [Ord(mString[I])]); end; if S <> '' then Result := Result + QuotedStr(S); end; { StringToDisplay }function DisplayToString(mDisplay: string): string; var I: Integer; S: string; B: Boolean; begin Result := ''; B := False; mDisplay := mDisplay; for I := 1 to Length(mDisplay) do if B then case mDisplay[I] of '''': begin if S <> '' then Result := Result + StringReplace(S, '''''', '''', [rfReplaceAll]); if Copy(mDisplay, I + 1, 1) = '''' then Result := Result + ''''; S := ''; B := False; end; else S := S + mDisplay[I]; end else case mDisplay[I] of '#', '''': begin if S <> '' then Result := Result + Chr(StrToIntDef(S, 0)); S := ''; B := mDisplay[I] = ''''; end; '$', '0'..'9', 'a'..'f', 'A'..'F': S := S + mDisplay[I]; end; if (not B) and (S <> '') then Result := Result + Chr(StrToIntDef(S, 0)); end; { DisplayToString }function StringEncrypt(mStr: string; mKey: string): string; var I, J: Integer; begin J := 1; Result := ''; for I := 1 to Length(mStr) do begin Result := Result + Char(Ord(mStr[I]) xor Ord(mKey[J])); if J + 1 <= Length(mKey) then Inc(J) else J := 1; end; { 自己加步骤 } end; { StringEncrypt }function StringDecrypt(mStr: string; mKey: string): string; var I, J: Integer; begin J := 1; Result := ''; { 自己加步骤 } for I := 1 to Length(mStr) do begin Result := Result + Char(Ord(mStr[I]) xor Ord(mKey[J])); if J + 1 <= Length(mKey) then Inc(J) else J := 1; end; end; { StringDecrypt } ///////End Source///////Begin Demo const cKey = '给你这一把钥匙,只能打开这一把锁';procedure TForm1.Button1Click(Sender: TObject); begin Memo2.Text := StringToDisplay(StringEncrypt(Memo1.Text, cKey)); end;procedure TForm1.Button2Click(Sender: TObject); begin Memo1.Text := StringDecrypt(DisplayToString(Memo2.Text), cKey); end; ///////End Demo
给你搞了这么久才发现你这算法和XOR $5A有什么区别? $D6 Xor $8C = $5Aprocedure TForm1.Button1Click(Sender: TObject); var s, s1: String; i: Integer; begin s:='中华人民共各国'; s1:=''; For i:=1 to Length(s) do begin s1:=s1+chr(ord(s[length(s)-i+1]) xor $5A); end; ShowMessage(S1); end;两次都用这个不就行了,浪费时间!
(*// 标题:字符串加密;pascal字符表示 说明:应用于文件加密 设计:Zswang 日期:2002-02-19 支持:[email protected] //*)///////Begin Source function StringToDisplay(mString: string): string; var I: Integer; S: string; begin Result := ''; S := ''; for I := 1 to Length(mString) do if mString[I] in [#32..#127] then S := S + mString[I] else begin if S <> '' then begin Result := Result + QuotedStr(S); S := ''; end; Result := Result + Format('#$%x', [Ord(mString[I])]); end; if S <> '' then Result := Result + QuotedStr(S); end; { StringToDisplay }function DisplayToString(mDisplay: string): string; var I: Integer; S: string; B: Boolean; begin Result := ''; B := False; mDisplay := mDisplay; for I := 1 to Length(mDisplay) do if B then case mDisplay[I] of '''': begin if S <> '' then Result := Result + StringReplace(S, '''''', '''', [rfReplaceAll]); if Copy(mDisplay, I + 1, 1) = '''' then Result := Result + ''''; S := ''; B := False; end; else S := S + mDisplay[I]; end else case mDisplay[I] of '#', '''': begin if S <> '' then Result := Result + Chr(StrToIntDef(S, 0)); S := ''; B := mDisplay[I] = ''''; end; '$', '0'..'9', 'a'..'f', 'A'..'F': S := S + mDisplay[I]; end; if (not B) and (S <> '') then Result := Result + Chr(StrToIntDef(S, 0)); end; { DisplayToString }function StringEncrypt(mStr: string; mKey: string): string; var I, J: Integer; begin J := 1; Result := ''; for I := 1 to Length(mStr) do begin Result := Result + Char(Ord(mStr[I]) xor Ord(mKey[J])); if J + 1 <= Length(mKey) then Inc(J) else J := 1; end; { 自己加步骤 } end; { StringEncrypt }function StringDecrypt(mStr: string; mKey: string): string; var I, J: Integer; begin J := 1; Result := ''; { 自己加步骤 } for I := 1 to Length(mStr) do begin Result := Result + Char(Ord(mStr[I]) xor Ord(mKey[J])); if J + 1 <= Length(mKey) then Inc(J) else J := 1; end; end; { StringDecrypt } ///////End Source///////Begin Demo const cKey = '给你这一把钥匙,只能打开这一把锁';procedure TForm1.Button1Click(Sender: TObject); begin Memo2.Text := StringToDisplay(StringEncrypt(Memo1.Text, cKey)); end;procedure TForm1.Button2Click(Sender: TObject); begin Memo1.Text := StringDecrypt(DisplayToString(Memo2.Text), cKey); end; ///////End Demo
procedure TForm1.Button1Click(Sender: TObject);
var s, s1: String;
begin
s:='中';
s1:='';
For i:=1 to Length(s) do
begin
s1:=s1+chr(ord(s[length-i+1]) xor $d6);
end;
For i:=1 to Length(s1) do
begin
s1[i]:=chr(ord(s1[i]) xor $8c);
end;
end;
var s, s1: String;
i: Integer;
begin
s:='中';
s1:='';
For i:=1 to Length(s) do
begin
s1:=s1+chr(ord(s[length-i+1]) xor $8c);
end;
For i:=1 to Length(s1) do
begin
s1[i]:=chr(ord(s1[i]) xor $d6);
end;
end;
这是第二个,没有测试
上不去呀
procedure TForm1.Button1Click(Sender: TObject);
var s, s1: String;
i: Integer;
begin
s:='中华人民共各国';
s1:='';
For i:=1 to Length(s) do
begin
s1:=s1+chr(ord(s[length(s)-i+1]) xor $8c);
end;
For i:=1 to Length(s1) do
begin
s1[i]:=chr(ord(s1[i]) xor $d6);
end;
ShowMessage(S1);
s:=S1;
s1:='';
For i:=1 to Length(s) do
begin
s1:=s1+chr(ord(s[length(s)-i+1]) xor $d6);
end;
For i:=1 to Length(s1) do
begin
s1[i]:=chr(ord(s1[i]) xor $8c);
end;
ShowMessage(S1);
end;
procedure TForm1.Button1Click(Sender: TObject);
var s, s1: String;
i: Integer;
begin
s:='中华人民共各国';
s1:='';
For i:=1 to Length(s) do
begin
s1:=s1+chr(ord(s[length(s)-i+1]) xor $8c);
end;
For i:=1 to Length(s1) do
begin
s1[i]:=chr(ord(s1[i]) xor $d6);
end;
ShowMessage(S1);
s:=S1;
s1:='';
For i:=1 to Length(s) do
begin
s1:=s1+chr(ord(s[length(s)-i+1]) xor $d6);
end;
For i:=1 to Length(s1) do
begin
s1[i]:=chr(ord(s1[i]) xor $8c);
end;
ShowMessage(S1);
end;
procedure TForm1.Button1Click(Sender: TObject);
var s, s1: String;
i: Integer;
begin
s:='中华人民共各国';
s1:='';
For i:=1 to Length(s) do
begin
s1:=s1+chr(ord(s[length(s)-i+1]) xor $8c);
end;
For i:=1 to Length(s1) do
begin
s1[i]:=chr(ord(s1[i]) xor $d6);
end;
ShowMessage(S1);
s:=S1;
s1:='';
For i:=1 to Length(s) do
begin
s1:=s1+chr(ord(s[length(s)-i+1]) xor $d6);
end;
For i:=1 to Length(s1) do
begin
s1[i]:=chr(ord(s1[i]) xor $8c);
end;
ShowMessage(S1);
end;
procedure TForm1.Button1Click(Sender: TObject);
var S:PChar;
begin
GetMem(S,4);
Form1.JiaMi('123',3,S);
ShowMessagE(StrPAs(S));
end;procedure TForm1.JiaMi(StrP: PChar; StrL: Integer; StrR: PChar);
var P1:PChar;
var P2:PChar;
var i:integer;
var C:Char;
var K:Char;
begin
P1:=StrP;
P2:=StrR;
For i:=1 to StrL do
begin
C:=P1^;
C:=Chr(Ord(C) xor $d6);
P2^:=C;
inc(P1);
inc(P2);
end;
dec(P2);
P1:=StrR;
While(P2>P1) do
begin
C:=P2^;
K:=P1^;
P2^:=K;
P1^:=C;
inc(P1);
dec(P2);
end; P1:=StrR;
P2:=StrR;
For i:=1 to StrL do
begin
C:=P1^;
C:=Chr(Ord(C) xor $8c);
P2^:=C;
inc(P1);
inc(P2);
end;
end;
你在一或一叹就回来了,所以加密接密一样的程序
procedure TForm1.Button2Click(Sender: TObject);
var c:char;
begin
c:='9';
c:=chr(ord(c) xor $d6);
c:=chr(ord(c) xor $d6);
showMessagE(c);
end;
可以上,里面有写好两个函数
因为很可能有些特殊符号之类,被意外截断
johnsonrao(johnson)第三次的可以了
ch81(missile):我再试试你的,马上就结贴。
标题:字符串加密;pascal字符表示
说明:应用于文件加密
设计:Zswang
日期:2002-02-19
支持:[email protected]
//*)///////Begin Source
function StringToDisplay(mString: string): string;
var
I: Integer;
S: string;
begin
Result := '';
S := '';
for I := 1 to Length(mString) do
if mString[I] in [#32..#127] then
S := S + mString[I]
else begin
if S <> '' then begin
Result := Result + QuotedStr(S);
S := '';
end;
Result := Result + Format('#$%x', [Ord(mString[I])]);
end;
if S <> '' then Result := Result + QuotedStr(S);
end; { StringToDisplay }function DisplayToString(mDisplay: string): string;
var
I: Integer;
S: string;
B: Boolean;
begin
Result := '';
B := False;
mDisplay := mDisplay;
for I := 1 to Length(mDisplay) do
if B then case mDisplay[I] of
'''': begin
if S <> '' then Result := Result + StringReplace(S, '''''', '''', [rfReplaceAll]);
if Copy(mDisplay, I + 1, 1) = '''' then Result := Result + '''';
S := '';
B := False;
end;
else S := S + mDisplay[I];
end
else case mDisplay[I] of
'#', '''': begin
if S <> '' then Result := Result + Chr(StrToIntDef(S, 0));
S := '';
B := mDisplay[I] = '''';
end;
'$', '0'..'9', 'a'..'f', 'A'..'F': S := S + mDisplay[I];
end;
if (not B) and (S <> '') then Result := Result + Chr(StrToIntDef(S, 0));
end; { DisplayToString }function StringEncrypt(mStr: string; mKey: string): string;
var
I, J: Integer;
begin
J := 1;
Result := '';
for I := 1 to Length(mStr) do begin
Result := Result + Char(Ord(mStr[I]) xor Ord(mKey[J]));
if J + 1 <= Length(mKey) then
Inc(J)
else J := 1;
end;
{ 自己加步骤 }
end; { StringEncrypt }function StringDecrypt(mStr: string; mKey: string): string;
var
I, J: Integer;
begin
J := 1;
Result := '';
{ 自己加步骤 }
for I := 1 to Length(mStr) do begin
Result := Result + Char(Ord(mStr[I]) xor Ord(mKey[J]));
if J + 1 <= Length(mKey) then
Inc(J)
else J := 1;
end;
end; { StringDecrypt }
///////End Source///////Begin Demo
const
cKey = '给你这一把钥匙,只能打开这一把锁';procedure TForm1.Button1Click(Sender: TObject);
begin
Memo2.Text := StringToDisplay(StringEncrypt(Memo1.Text, cKey));
end;procedure TForm1.Button2Click(Sender: TObject);
begin
Memo1.Text := StringDecrypt(DisplayToString(Memo2.Text), cKey);
end;
///////End Demo
$D6 Xor $8C = $5Aprocedure TForm1.Button1Click(Sender: TObject);
var s, s1: String;
i: Integer;
begin
s:='中华人民共各国';
s1:='';
For i:=1 to Length(s) do
begin
s1:=s1+chr(ord(s[length(s)-i+1]) xor $5A);
end;
ShowMessage(S1);
end;两次都用这个不就行了,浪费时间!
标题:字符串加密;pascal字符表示
说明:应用于文件加密
设计:Zswang
日期:2002-02-19
支持:[email protected]
//*)///////Begin Source
function StringToDisplay(mString: string): string;
var
I: Integer;
S: string;
begin
Result := '';
S := '';
for I := 1 to Length(mString) do
if mString[I] in [#32..#127] then
S := S + mString[I]
else begin
if S <> '' then begin
Result := Result + QuotedStr(S);
S := '';
end;
Result := Result + Format('#$%x', [Ord(mString[I])]);
end;
if S <> '' then Result := Result + QuotedStr(S);
end; { StringToDisplay }function DisplayToString(mDisplay: string): string;
var
I: Integer;
S: string;
B: Boolean;
begin
Result := '';
B := False;
mDisplay := mDisplay;
for I := 1 to Length(mDisplay) do
if B then case mDisplay[I] of
'''': begin
if S <> '' then Result := Result + StringReplace(S, '''''', '''', [rfReplaceAll]);
if Copy(mDisplay, I + 1, 1) = '''' then Result := Result + '''';
S := '';
B := False;
end;
else S := S + mDisplay[I];
end
else case mDisplay[I] of
'#', '''': begin
if S <> '' then Result := Result + Chr(StrToIntDef(S, 0));
S := '';
B := mDisplay[I] = '''';
end;
'$', '0'..'9', 'a'..'f', 'A'..'F': S := S + mDisplay[I];
end;
if (not B) and (S <> '') then Result := Result + Chr(StrToIntDef(S, 0));
end; { DisplayToString }function StringEncrypt(mStr: string; mKey: string): string;
var
I, J: Integer;
begin
J := 1;
Result := '';
for I := 1 to Length(mStr) do begin
Result := Result + Char(Ord(mStr[I]) xor Ord(mKey[J]));
if J + 1 <= Length(mKey) then
Inc(J)
else J := 1;
end;
{ 自己加步骤 }
end; { StringEncrypt }function StringDecrypt(mStr: string; mKey: string): string;
var
I, J: Integer;
begin
J := 1;
Result := '';
{ 自己加步骤 }
for I := 1 to Length(mStr) do begin
Result := Result + Char(Ord(mStr[I]) xor Ord(mKey[J]));
if J + 1 <= Length(mKey) then
Inc(J)
else J := 1;
end;
end; { StringDecrypt }
///////End Source///////Begin Demo
const
cKey = '给你这一把钥匙,只能打开这一把锁';procedure TForm1.Button1Click(Sender: TObject);
begin
Memo2.Text := StringToDisplay(StringEncrypt(Memo1.Text, cKey));
end;procedure TForm1.Button2Click(Sender: TObject);
begin
Memo1.Text := StringDecrypt(DisplayToString(Memo2.Text), cKey);
end;
///////End Demo
那我要怎样加算法才能有两次加密呢?
{ 自己加步骤 } 怎么加呀?
不要再给我发关于这个贴的信息了。
No Possible