-
Jun 30th, 2005, 06:04 AM
#1
Thread Starter
Supreme User
[DELPHI] - Encrypting String Values
You can find this article here: http://bdn.borland.com/article/0,1410,28325,00.html
or view the code:
Code:
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
Button2: TButton;
Edit3: TEdit;
procedure Button1Click(Sender: TObject);
function EnDeCrypt(const Value : String) : String;
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function TForm1.EnDeCrypt(const Value : String) : String;
var
CharIndex : integer;
begin
Result := Value;
for CharIndex := 1 to Length(Value) do
Result[CharIndex] := chr(not(ord(Value[CharIndex])));
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Edit2.Text := EnDeCrypt(Edit1.Text);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Edit3.Text := EnDeCrypt(Edit2.Text);
end;
-
Jul 1st, 2005, 05:51 AM
#2
Thread Starter
Supreme User
Re: [DELPHI] - Encrypting String Values
This example can also be used to achieve the same thing:
Note: Edit the Random(x) value for different randon encryption
Encrypt:
Code:
procedure Encrypt;
var S:String;
i:integer;
Begin
Randseed:= 12;
S:= '';
for i:=1 to length(txtMain.text) do
Begin
S:= S + chr(ord(txtMain.text[i]) + Random(10) + 1);
end;
txtMain.text:=S;
end;
Decrypt:
Code:
Procedure Decrypt;
Var S:string;
i:integer;
Begin
Randseed:= 12;
S:= '';
for i:=1 to length(txtMain.text) do
Begin
S:= S + chr(ord(txtMain.text[i]) - Random(10) - 1);
end;
txtMain.text:= S;
end;
-
Jul 12th, 2005, 12:21 AM
#3
Re: [DELPHI] - Encrypting String Values
Is Delphi's random number generation only dependant on the seed value? Seems almost a risky way to go about it if it's not, it doesn't depend on hardware configuration, clock time, or anything else?
Bill
-
Jul 12th, 2005, 11:40 AM
#4
Thread Starter
Supreme User
Re: [DELPHI] - Encrypting String Values
There are many different methods, this is only basic. I had one before which truly encrypted the text. Handled large documents too
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|