Рефераты. Защита информации от несанкционированного доступа

end;

end;

procedure TOptionsForm.BitBtn1Click(Sender: TObject);

var i: integer;

begin

UsedMethodsBox.Clear;

for i:=1 to QolMethods do

begin

UsedMethodsBox.Items.Add(Methods[i].MethodName);

Used[i]:=true;

end;

EnableKeys(True);

end;

procedure TOptionsForm.UsedMethodsBoxClick(Sender: TObject);

var

i: integer;

begin

If (UsedMethodsBox.ItemIndex=-1)or

(UsedMethodsBox.Items.Count=0) then

begin

EnableKeys(False);

DescMemo.Clear;

Exit;

end else

begin

EnableKeys(True);

end;

i:=MethodIndex(UsedMethodsBox.Items.Strings[UsedMethodsBox.ItemIndex]);

if i=0 then exit;

DirectionGroup.ItemIndex:=UsedMethods[i].Direction-1;

KeyEdit.MaxLength:=Methods[i].KeyMaxLength;

KeyEdit.Text:=String(UsedMethods[i].Key);

WayCountEdit.Value:=UsedMethods[i].WayCount;

DescMemo.Clear;

DescMemo.Lines.Append(Methods[i].MethodDescription);

end;

procedure TOptionsForm.DirectionGroupExit(Sender: TObject);

var

i: integer;

begin

If (UsedMethodsBox.ItemIndex=-1)or

(UsedMethodsBox.Items.Count=0) then Exit;

i:=MethodIndex(UsedMethodsBox.Items.Strings[UsedMethodsBox.ItemIndex]);

if i=0 then exit;

UsedMethods[i].Direction:=DirectionGroup.ItemIndex+1;

end;

procedure TOptionsForm.KeyEditExit(Sender: TObject);

var

i: integer;

begin

If (UsedMethodsBox.ItemIndex=-1)or

(UsedMethodsBox.Items.Count=0) then

Exit;

i:=MethodIndex(UsedMethodsBox.Items.Strings[UsedMethodsBox.ItemIndex]);

if i=0 then exit;

StrPCopy(UsedMethods[i].Key,KeyEdit.Text);

end;

procedure TOptionsForm.WayCountEditExit(Sender: TObject);

var

i: integer;

begin

If (UsedMethodsBox.ItemIndex=-1)or

(UsedMethodsBox.Items.Count=0) then

Exit;

i:=MethodIndex(UsedMethodsBox.Items.Strings[UsedMethodsBox.ItemIndex]);

if i=0 then exit;

UsedMethods[i].WayCount:=WayCountEdit.Value;

end;

procedure TOptionsForm.FormClose(Sender: TObject;

var Action: TCloseAction);

var

i: integer;

begin

Action:=caHide;

for i:=1 to QolMethods do

begin

if Used[i] then

begin

if StrLen(UsedMethods[i].Key)<Methods[i].KeyMinLength then

begin

ShowMessage(Methods[i].MethodName+': '+Methods[i].KeyMinMessage);

Action:=caNone;

Exit;

end else

if StrLen(UsedMethods[i].Key)>Methods[i].KeyMaxLength then

begin

ShowMessage(Methods[i].MethodName+': '+Methods[i].KeyMaxMessage);

Action:=caNone;

Exit;

end;

end;

end;

end;

end.

unit ProgressUnit;

interface

uses

Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,

ComCtrls, StdCtrls;

type

TProgressForm = class(TForm)

Label1: TLabel;

PBOne: TProgressBar;

PBAll: TProgressBar;

Label2: TLabel;

private

{ Private declarations }

public

Current: integer;

procedure UpdateProgress(fn: String;perc:integer;Cap:String);

procedure InitProgress(qol:integer;Cap:String);

procedure EndProcess;

{ Public declarations }

end;

var

ProgressForm: TProgressForm;

implementation

{$R *.DFM}

procedure TProgressForm.EndProcess;

begin

inc(current);

end;

procedure TProgressForm.UpdateProgress;

begin

ProgressForm.Caption:=Cap+' - '+inttostr(round(PBAll.Position*100/PBAll.Max))+'%';

Label1.Caption:=Cap+fn;

PBOne.Position:=perc;

PBAll.Position:=100*Current+perc;

end;

procedure TProgressForm.InitProgress;

begin

Caption:=Cap;

Label1.Caption:='Подготовка...';

PBOne.Position:=0;

PBOne.Max:=100;

PBAll.Position:=0;

PBAll.Max:=qol*100;

Current:=0;

end;

end.

unit TestUnit;

interface

uses

Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,

StdCtrls, ActnList, ExtCtrls, ComCtrls, ToolWin, Grids, Outline, DirOutln,

Buttons, ShellApi, Registry;

type

TMainForm = class(TForm)

Label1: TLabel;

RecurseBox: TCheckBox;

BitBtn1: TBitBtn;

StaticText1: TStaticText;

MainKey: TEdit;

BitBtn2: TBitBtn;

Open: TOpenDialog;

BitBtn3: TBitBtn;

BitBtn4: TBitBtn;

BitBtn5: TBitBtn;

BitBtn6: TBitBtn;

files: TListBox;

procedure FileDrop(var Msg: TWMDropFiles); message WM_DROPFILES;

procedure AddCmdLine(var msg: TMessage); message WM_USER;

procedure FormCreate(Sender: TObject);

procedure BitBtn1Click(Sender: TObject);

procedure DoCommandLine(S: String);

procedure StopDblClick(Sender: TObject);

procedure GoDblClick(Sender: TObject);

procedure GenerateKey;

function DecodeKey: integer;

procedure BitBtn2Click(Sender: TObject);

procedure BitBtn3Click(Sender: TObject);

procedure BitBtn6Click(Sender: TObject);

private

{ Private declarations }

public

end;

var

MainForm: TMainForm;

Decode: boolean;

implementation

uses CodingUnit, OptionsUnit, ProgressUnit;

{$R *.DFM}

procedure TMainForm.GenerateKey;

var

i,k,l: integer;

s: string;

begin

for i:=1 to QolMethods do

begin

If Used[i] then

begin

k:=random(9)+1;

s:=concat(s,Methods[i].MethodKey);

s:=concat(s,IntToStr(k));

l:=strlen(UsedMethods[i].Key)+k*6;

s:=concat(s,Format('%2d',[l]));

s:=concat(s,StrPas(UsedMethods[i].Key));

s:=concat(s,Format('%2d',[strlen(UsedMethods[i].Key)+k*5+UsedMethods[i].Direction]));

s:=concat(s,Format('%2d',[strlen(UsedMethods[i].Key)+k*4+UsedMethods[i].WayCount]));

end;

end;

for i:=1 to length(s) do if s[i]=' ' then s[i]:='-';

MainKey.Text:=S;

end;

function TMainForm.DecodeKey;

var

i,k,l,t: integer;

s: string;

begin

Result:=0;

s:=MainKey.Text;

for i:=1 to length(s) do if s[i]='-' then s[i]:='0';

try

while s<>'' do

begin

t:=MethodByChar(s[1]);

Used[t]:=true;

delete(s,1,1);

k:=strtoint(copy(s,1,1));

delete(s,1,1);

l:=strtoint(copy(s,1,2))-k*6;

delete(s,1,2);

StrPCopy(UsedMethods[t].Key,copy(s,1,l));

delete(s,1,l);

UsedMethods[t].Direction:=strtoint(copy(s,1,2))-l-k*5;

delete(s,1,2);

UsedMethods[t].WayCount:=strtoint(copy(s,1,2))-l-k*4;

delete(s,1,2);

end;

except

on E:Exception do Result:=1;

end;

end;

Procedure TMainForm.DoCommandLine(S: String);

var

i: integer;

tmp: string;

begin

System.CmdLine:=PChar(S);

tmp:=ParamStr(1);

if CompareText(tmp,'/D')=0 then

begin

// декодирование

Decode:=true;

StaticText1.Caption:='Введите ключ';

MainKey.Color:=clWindow;

MainKey.ReadOnly:=false;

MainKey.Text:='';

if ParamCount>1 then

begin

for i:=2 to ParamCount do

begin

Files.Items.Add(ParamStr(i));

end;

end;

end else

begin

Страницы: 1, 2, 3, 4, 5



2012 © Все права защищены
При использовании материалов активная ссылка на источник обязательна.