Registriert seit: 17. Feb 2004
Ort: Coburg
1.860 Beiträge
FreePascal / Lazarus
|
Re: Text-Verschlüsselungsprogramm
9. Mär 2004, 20:33
Hier ist der Code, ich hab erst die Verschlüsselungs-Prozedur umgeschrieben:
Delphi-Quellcode:
unit Ulticrypt_U;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
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 }
public
{ Public-Deklarationen }
end;
var
TCryptForm: TCryptForm;
implementation
{$R *.dfm}
procedure Button1Click( 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 TTCryptForm.Button2Click(Sender: TObject);
var S, P: string;
I, J:integer;
begin
S:=Memo2.Text;
P:=Edit3.Text;
J := 1;
try
for I := 1 to Length(S) do
begin
S[I] := Chr(Ord(S[I]) xor Ord(P[J]));
Inc(J);
if J > Length(P) then
J := 1;
Memo1.Text:=S;
end;
except
ShowMessage(' Sie müssen ein Passwort eingeben!');
end;
end;
end.
Julian J. Pracht
|
|
Zitat
|