22-03-2008, 04:32 PM
السلام عليكم و رحمة الله
طريقة بسيطة لتشفير اي ملف و حل تشفيره
الملفات المصدرية مرفقة
بالتوفيق
طريقة بسيطة لتشفير اي ملف و حل تشفيره
الملفات المصدرية مرفقة
PHP كود :
(*
Simple Encrypt for Educational use
Coded By STRELiTZIA 03/22/2008
---
You can change code and use it WITHOUT REMOVE MY NAME :)
---
"OnClick Button Action"
procedure EncrOrDecr(_InPutFile, _OutPutFile: string; Key [Simple integer Key], Param [1 = Encrypt] [2 = Decrypt] [Other = Nothing]: integer);
*)
unit MainFrm;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Gauges, ExtCtrls, jpeg;
type
TMain = class(TForm)
OpenDialog: TOpenDialog;
SaveDialog: TSaveDialog;
Pnl: TPanel;
ProgressGge: TGauge;
KeyEdt: TEdit;
KeyLbl: TLabel;
OutPutFileEdt: TEdit;
InPutFileEdt: TEdit;
OpenBtn: TButton;
InPutFileLbl: TLabel;
OutPutFileLbl: TLabel;
SeparatorLbl: TLabel;
CoderLbl: TLabel;
LogoImg: TImage;
EncryptBtn: TButton;
DecryptBtn: TButton;
procedure OpenBtnClick(Sender: TObject);
procedure KeyEdtKeyPress(Sender: TObject; var Key: Char);
procedure EncryptBtnClick(Sender: TObject);
procedure DecryptBtnClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Main: TMain;
implementation
uses XpMan; (* <<-- For Windows Xp Look :) *)
{$R *.dfm}
(* ______________________________________________________*)
procedure EncrOrDecr(_InPutFile, _OutPutFile: string; Key (* Simple integer Key *), Param (* [1 = Encrypt] [2 = Decrypt] [Other = Nothing] *): integer);
var
InPutFileStream, OutPutFileStream: TFileStream;
_ReadBuffer, _WriteBuffer: Char;
i: integer;
begin
InPutFileStream := TFileStream.Create(_InPutFile, FmOpenRead); (* Create FileStream and Open our file in Read mode *)
OutPutFileStream := TFileStream.Create(_OutPutFile, FmOpenWrite or FmCreate or FmSharedEnyWrite); (* Create new FileStream for our new file in write mode *)
Main.ProgressGge.MaxValue := InPutFileStream.Size; (* Initialization to InPutFile Size *)
for i := 0 to InPutFileStream.Size - 1 do
begin
InPutFileStream.Read(_ReadBuffer, SizeOf(_ReadBuffer));
case Param of
1: begin _WriteBuffer := Char(Pchar(_ReadBuffer) + Key); (* if Param = 1 Encrypt called *) end;
2: begin _WriteBuffer := Char(Pchar(_ReadBuffer) - Key); (* if Param = 2 Decrypt called *) end;
end;
Main.ProgressGge.Progress := Main.ProgressGge.Progress + 1;
OutPutFileStream.Write(_WriteBuffer, SizeOf(_WriteBuffer));
end;
ShowMessage('Complete... :) [Simple Encrypt fo EDUCATIONAL USE]');
InPutFileStream.Free;
OutPutFileStream.Free;
Main.ProgressGge.Progress := 0; (* Reset *)
end;
(* ______________________________________________________*)
procedure TMain.OpenBtnClick(Sender: TObject);
begin
if Opendialog.Execute then
begin
InPutFileEdt.Text := OpenDialog.FileName;
OutPutFileEdt.Text := OpenDialog.FileName + '.Out';
end;
end;
(* ______________________________________________________*)
procedure TMain.KeyEdtKeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9', #8]) then Key := #0; (* Accept only number [#8 for Remove key] *)
end;
(* ______________________________________________________*)
procedure TMain.EncryptBtnClick(Sender: TObject);
begin
if (InPutFileEdt.Text <> '') and (OutPutFileEdt.Text <> '') and (KeyEdt.Text <> '') then
EncrOrDecr(InPutFileEdt.Text, OutPutFileEdt.Text, StrToInt(KeyEdt.Text), 1) else (* Param = 2 [ENCRYPT]*)
ShowMessage('ERROR : [Informations missing]');
end;
(* ______________________________________________________*)
procedure TMain.DecryptBtnClick(Sender: TObject);
begin
if (InPutFileEdt.Text <> '') and (OutPutFileEdt.Text <> '') and (KeyEdt.Text <> '') then
EncrOrDecr(InPutFileEdt.Text, OutPutFileEdt.Text, StrToInt(KeyEdt.Text), 2) else (* Param = 2 [DECRYPT]*)
ShowMessage('ERROR : [Informations missing]');
end;
end.
بالتوفيق