...String-Encryption benutzen?
Autor: Mostafa Sarbazzadeh
//Uses Math
var
Form1: TForm1;
S: string[255];
C: array[0..255] of Byte absolute S;
I: Integer;
Index: Integer;
implementation
{$R *.dfm}
function EnCode(Pass: string): ShortString;
external 'Enc.Dll';
function Decode(Coded: string): ShortString;
external 'Enc.Dll';
procedure TForm1.Button1Click(Sender: TObject);
var
AFrom, ATo: Integer;
R, A, Count: Integer;
Chars, Z1, Z2: string;
begin
AFrom := 41;
ATo := 120;
S := Trim(Edit1.Text);
SpinEdit1.Value := (Length(S) * 2658);
for I := 1 to Ord(S[0]) do C[I] := SpinEdit1.Value xor C[I];
Randomize;
Z1 := Char(RandomRange(AFrom, ATo));
Z2 := Char(RandomRange(AFrom, ATo));
S := Z1 + S + Z2;
Index := (Length(S) div 2);
Count := Index;
for A := 1 to 9 do
begin
Randomize;
R := RandomRange(AFrom, ATo);
Chars := Char(R);
Insert(Chars, S, Index);
Inc(Count, 1);
end;
Edit2.Text := S;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
S := Edit2.Text;
Delete(S, Index, 9);
Delete(S, 1,1);
Delete(S, Length(S), 1);
for I := 1 to Length(S) do S[I] := Char((SpinEdit1.Value) xor Ord(C[I]));
Edit3.Text := S;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
Edit2.Text := EnCode(Edit1.Text);
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
Edit3.Text := Decode(Edit2.Text);
end;
end.
printed from
www.swissdelphicenter.ch
developers knowledge base