Главная    Почта    Новости    Каталог    Одноклассники    Погода    Работа    Игры     Рефераты     Карты
  
по Казнету new!
по каталогу
в рефератах

Защита данных от несанкционированного доступа

          6: Mas[8*(i-1)+j]:=MasByte[67-8*j];
                     7: Mas[8*(i-1)+j]:=MasByte[69-8*j];
                     8: Mas[8*(i-1)+j]:=MasByte[71-8*j]
                   end;
               T[0] := ord(Password[k]);
               if k < length(Password) then inc(k) else k := 1;
               for i:= 1 to 64 do
                 begin
                   NowPos := 100*Position/DirInfo.Size;
                   inc(Position, 2);
                   If NowPos > 100 then NowPos := 100;
                   Str(Round(NowPos):3, Pos);
                   if OptInd = 0 then
                     begin
                       GoToXY(77, 1);
                       Write(Pos + '%');
                     end;
                   T[i] := (A * T[i-1] + C) mod M;

                   Code:=Mas[i];
                   Code:=T[i] xor Code;
                   Mas[i] := Code;
                 end;
               MasEnd := Mas;
               for i := 1 to 64 do Write(OutF, MasEnd[i]);
             end;
           until eof(InpF);
               GotoXY(77, 1);
               write('100%');
               MyMessageBox('Файл '+ InputFileName + ' расшифрован в ' +
                        OutputFileName, nil, mfInformation+mfOkButton);
           Close(InpF);
           if OptFile = 1 then Erase(InpF);
           Close(OutF);
         end
           else  MyMessageBox('Файл '+ InputFileName + ' не существует!',
                    nil, mfInformation+mfOkButton);

         end
       else MyMessageBox('      Ошибка ввода пароля!!!', nil,
                         mfError+mfOkButton);
     end
   else MyMessageBox('          Файл не выбран!!!', nil,
                     mfError+mfOkButton);
 end;


 {Опции криптографии}
 constructor TOptions.Init;
 var
   R    : TRect;
   Q, Q1: PView;
   Butt : TRadioButtons;
 begin
   R.Assign(0, 0, 60, 11);
   inherited Init(R, 'Криптография');
   Options := Options or ofCentered;

   R.Assign(10, 8, 20, 10);
   Insert(New(PButton, Init(R, '~А~га', cmOK, bfDefault)));


   R.Assign(40, 8, 50, 10);
   Insert(New(PButton, Init(R, '~Н~ека', cmCancel, bfNormal)));

   R.Assign(2, 2, 25, 3);
   Insert(New(PLabel, Init(R, 'Исходный файл:', Q)));

   R.Assign(5, 4, 21, 6);
   Q:=New(PRadioButtons, Init(R,
     NewSItem('~Н~е удалять',
     NewSItem('~У~далять', nil))));
   Insert(Q);

   R.Assign(27, 2, 45, 3);
   Insert(New(PLabel, Init(R, 'Индикатор:', Q1)));

   R.Assign(30, 4, 50, 6);
   Q1:=New(PRadioButtons, Init(R,
     NewSItem('~В~ысвечивать',
     NewSItem('~Н~е высвечивать', nil))));
 Insert(Q1);
 end;

 {Изменение пароля на вход в систему}
 procedure Passwords;
 var
   Ps, Ps1: string;
   I      : byte;
   tmp    : char;
 begin
   Ps := '';
   Ps1 := '';
   InputBox('П А Р О Л Ь', 'Введите пароль:', Ps, 255);
   for i:= 1 to length(Ps) do Ps[i] :=chr(ord(Ps[i]) xor 27);
   if Ps <> Pass then
     begin
       MyMessageBox('        Неверный пароль!!!', nil, mfError+mfOkButton);
       ClrScr;
       writeln('Несанкционированный доступ!');
       Halt;
     end;
   InputBox('И З М Е Н Е Н И Е   П А Р О Л Я',
      'Введите новый пароль:', Ps, 255);
   InputBox('И З М Е Н Е Н И Е   П А Р О Л Я',
      '      Повторите ввод:', Ps1, 255);
   if (Ps = Ps1) and (Ps <> '') then
     begin
       Assign(FilePass, 'system.res');
       Rewrite(FilePass);
       for i := 1 to length(PS) do
         begin
           tmp := chr(ord(Ps[i]) xor 27);
           Write(FilePass, tmp);
         end;
       Close(FilePass);
     end
      else    MyMessageBox('         Ошибка    ввода    пароля!!!',    nil,
 mfError+mfOkButton);

 end;

 {Обработка ошибок}
 procedure CheckExec;
 var
   St: string;
 begin
   Str(DOSError, St);
   case DOSError of
      2: MyMessageBox('          Ошибка DOS  № ' +
           St + '         "Файл не найден"',
           nil, mfError + mfOkButton);
      3: MyMessageBox('          Ошибка DOS  № ' +
           St + '      "Путь не найден"',
           nil, mfError + mfOkButton);
      5: MyMessageBox('          Ошибка DOS  № ' +
           St + '"Неверный код доступа к файлу"',
           nil, mfError + mfOkButton);
      6: MyMessageBox('          Ошибка DOS  № ' +
           St + '"Неверный код системного обработчика файла"',
           nil, mfError + mfOkButton);
      8: MyMessageBox('          Ошибка DOS  № ' +
           St + '         "Недостаточно памяти"',
           nil, mfError + mfOkButton);
     10: MyMessageBox('          Ошибка DOS  № ' +
           St + '            "Неверная среда"',
           nil, mfError + mfOkButton);
     11: MyMessageBox('          Ошибка DOS  № ' +
           St + '       "Неправильный формат"',
           nil, mfError + mfOkButton);
     18: MyMessageBox('          Ошибка DOS  № ' +
           St + '"Нет свободных обработчиков для файлов"',
           nil, mfError + mfOkButton);
   end;
 end;

 procedure MakeComFile(k: byte);
 const
     S      :   array   [1..4]   of    string    =    ('c:sub_rosaplus.',
 'c:sub_rosapassw.',
                                                      'c:sub_rosablock.',
 'c:sub_rosakeydisk.');
   Size : array [1..4] of word = (1068, 204, 617, 2118);
   Inden: array [1..4, 1..3] of byte = ((ord('ы'), 26      , ord('Р')),
                                        (ord('ы'), 39      , ord('Р')),
                                        (ord('щ'), ord('Й'), ord('[pic]')),
                                        (ord('щ'), ord('А'), ord('')));
 var
   I, Tmp           : byte;
   F                : array [1..4, 1..2] of file ;
   M                : array [1..2200] of byte ;
 NumRead, NumWritten: Word;

 begin
   assign(F[k, 1], S[k]); reset(F[k, 1], 1);
   assign(F[k, 2], S[k]+'com'); rewrite(F[k, 2], 1);
   for i := 1 to 3 do
     begin
       BlockRead(F[k, 1], tmp, 1, NumRead);
       BlockWrite(F[k, 2], Inden[k, i], 1, NumWritten);
     end;
   BlockRead(F[k, 1], M, Size[k]-3, NumRead);
   BlockWrite(F[k, 2], M, Size[k]-3, NumWritten);
   close(F[k, 1]); close(F[k, 2]);
 end;

 procedure DelComFile(k: byte);
 const
 {  S: array [1..4] of string =
      ('plus.com', 'passw.com', 'block.com', 'keydisk.com');}
 S    : array [1..4] of string = ('c:sub_rosaplus.com',
                                  'c:sub_rosapassw.com',
                                  'c:sub_rosablock.com',
                                  'c:sub_rosakeydisk.com');
 var
   F: array [1..4] of file;
 begin
   Assign(F[k], S[k]);
   Erase(F[k]);
 end;

 {**************************************************************************
 **}
 {*----------=========== Д О П И С А Т Ь   К   Ф А Й Л У ==========---------
 -*}
 {**************************************************************************
 **}
 procedure Plus(WhatDo: string);
 var
   FileStr, Err: string;
   CmdLine     : string;
   I           : byte;
   FileName    : FNameStr;
   Regs        : Registers;
 begin
   {Проверка условий}
   if Length(FName) > 3 then
     begin
       if (copy(FName, length(FName)-2, 3) = 'EXE') or
         (copy(FName, length(FName)-2, 3) = 'COM')
         then
           begin
             {Преобразование имени файла}
             for i:= length(fname) downto 1 do
               if fname[i] = '' then
                 begin
                   CmdLine := copy(FName, i+1, length(FName) - i);
                   break;
                 end;
             for i := 1 to length(CmdLine) do
               if CmdLine[i] in ['A'..'Z'] then
                 CmdLine[i] := chr(ord(CmdLine[i]) + 32);
             for i := 1 to length(MainDir) do
               if MainDir[i] in ['A'..'Z'] then
                 MainDir[i] := chr(ord(MainDir[i]) + 32);
             MakeComFile(1);
             If WhatDo = SetPass then MakeComFile(2);
             If WhatDo = KeyDisk then MakeComFile(4);
             {Выполнить дописывание}
             SwapVectors;
             Exec( MainDir + 'plus.com  ',  CmdLine  +  '  '  +  MainDir  +
 WhatDo);
             SwapVectors;
             DelComFile(1);
             If WhatDo = SetPass then DelComFile(2);
             If WhatDo = KeyDisk then DelComFile(4);
             {Обработчик ошибок}
             if DosError <> 0 then
               CheckExec
             else
               begin
                 regs.ah := $4D;
                 with regs do
                 msdos(regs);
                 case Regs.AH of
                    0 : MyMessageBox(' Файл ' + FName + ' защищен.',
                          nil, mfInformation + mfOkButton);
                    1 : MyMessageBox('      Ctrl-C или Ctrl-Break.',
                          nil, mfError + mfOkButton);
                    2 : MyMessageBox('   Критическая ошибка устройства.',
                          nil, mfError + mfOkButton);
                    3 : MyMessageBox('        TSR - программа.',
                          nil, mfError + mfOkButton);
                 end;
               end;
           end
         else MyMessageBox('     Ошибка выбора файла !!! ',
                nil, m
Пред.678910След.
скачать работу

Защита данных от несанкционированного доступа

 

Отправка СМС бесплатно

На правах рекламы


ZERO.kz
 
Модератор сайта RESURS.KZ