Registriert seit: 27. Apr 2003
Ort: Bad Honnef
1.644 Beiträge
Delphi 2009 Professional
|
Re: Text-Verschlüsselungsprogramm
9. Mär 2004, 20:37
Hallo,
so sollte es gehen:
Delphi-Quellcode:
...
TTCryptForm = class(TForm)
Label1: TLabel;
Label2: TLabel;
Button1: TButton;
Edit3: TEdit;
Label3: TLabel;
memText: TMemo;
Memo2: TMemo;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private-Deklarationen }
procedure SaveCrypt(const Filename: TFilename);
public
{ Public-Deklarationen }
end;
...
procedure TFormCrypt.SaveCrypt(const Filename: TFilename);
var
MStream : TMemoryStream;
FileStream : TFilestream;
aByte : Byte;
begin
MStream:=TMemoryStream.Create;
FileStream:=TFilestream.Create(Filename,fmCreate);
Try
memText.SaveToStream(MStream); // Memo in einen MemoryStream speichern
MStream.Position:=0;
While MStream.Position<MStream.Size do
begin
MStream.Read(aByte,SizeOf(Byte));
aByte:=aByte xor iKey; // Verschlüsselung
FileStream.Write(aByte,SizeOf(Byte));
end;
Finally
MStream.Free;
Filestream.Free;
end;
end;
...
procedure Button1Click(Sender : TObject);
begin
SaveCrypt('c:\Text.cyt');
end;
...
I come from outer space to save the human race
|