Разработка генератора паролей

Курсовой проект - Компьютеры, программирование

Другие курсовые по предмету Компьютеры, программирование

p>При требовании пользователя главный модуль открывает сгенерированные пароли.

Сначала он обращается в файл с паролями, откуда получает зашифрованный пароль. Зашифрованный пароль отправляется из главной формы в модуль дешифрации, откуда приходит назад в форму расшифрованный.

 

Приложение 4

 

Основная форма:kurs;

interface.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ImgList, Vcl.StdCtrls, Vcl.Grids,.Imaging.jpeg, Vcl.ExtCtrls, Vcl.Menus, Vcl.Imaging.pngimage, Clipbrd,, generate, coder, decoder, about, ShellApi;Pass=Record:boolean;

password:string[100];:integer;:string[100];

End;= class(TForm): TStringGrid;: TMainMenu;: TMenuItem;: TMenuItem;: TMenuItem;: TMenuItem;: TMenuItem;: TMenuItem;: TMenuItem;: TMenuItem;: TMenuItem;: TButton;: TImage;

OpenDialog1: TOpenDialog;: TSaveDialog;: TLabel;

Label4: TLabel;: TLabel;: TLabel;

Label1: TLabel;: TButton;: TEdit;: TEdit;: TEdit;: TLabel;: TLabel;: TButton;: TButton;: TEdit;: TButton;: TLabel;: TLabel;FormCreate(Sender: TObject);AddPasswordClick(Sender: TObject);TablicaSelectCell(Sender: TObject; ACol, ARow: Integer;CanSelect: Boolean);TablicaMouseWheelDown(Sender: TObject; Shift: TShiftState;: TPoint; var Handled: Boolean);TablicaMouseWheelUp(Sender: TObject; Shift: TShiftState;: TPoint; var Handled: Boolean);N3Click(Sender: TObject);N2Click(Sender: TObject);N5Click(Sender: TObject);SecuritybuttonClick(Sender: TObject);N9Click(Sender: TObject);Button1Click(Sender: TObject);N4Click(Sender: TObject);SaveButtonClick(Sender: TObject);PasswordButtonClick(Sender: TObject);N13Click(Sender: TObject);FormClose(Sender: TObject; var Action: TCloseAction);N12Click(Sender: TObject);

{ Private declarations };: TForm1;

Gener: TGenerate;: TCode;: TDecode;

i,n,pis:integer;: file of Pass;,namer,confrm,reader,reader2,j:shortstring;,newdoc:boolean;:Pass;

decode.cipher(zap.password,zap.dlin)theninformationlabel.Caption:=beginnewpassword1.Text=newpassword2.textthen(f,0);.password:=code.cipher(newpassword1.text,length(newpassword1.text));.dlin:=length(newpassword1.text);(f,zap);.Text:=;.Text:=;.Text:=;.Caption:=;informationlabel.Caption:=;;pswchange:=true;newpassword1.Text=newpassword2.textthenSaveDialog1.Executethen:=SaveDialog1.FileName+.psw;(f,namer);(f);(f,0);.password:=code.cipher(newpassword1.text,length(newpassword1.text));.dlin:=length(newpassword1.text);(f,zap);.Text:=;.Text:=;.Text:=;.Caption:=;(f,1);I:=1toTablica.RowCountdo((Tablica.Cells[0,i]=)(tablica.Cells[1,i]=)(tablica.Cells[4,i]=))thencontinuebeginTablica.Cells[0,i]=thenzap.flag:=falsezap.flag:=true;.password:=code.cipher(tablica.Cells[1,i],length(tablica.Cells[1,i]));.dlin:=length(tablica.Cells[1,i]);.zamet:=tablica.Cells[4,i];(f,zap);;;endinformationlabel.Caption:=;:=false;pswchange:=false;;TForm1.SecuritybuttonClick(Sender:TObject);.ClientHeight:=509;;TForm1.Button1Click(Sender:TObject);.ClientHeight:=296;;TForm1.FormClose(Sender:TObject;varAction:TCloseAction);PSWChange=truethen">{$R *.dfm}TForm1.AddPasswordClick(Sender: TObject);.RowCount:=Tablica.RowCount+1;.cells[2,Tablica.RowCount-1]:=?;.cells[3,Tablica.RowCount-1]:=d;.cells[5,Tablica.RowCount-1]:=?;;TForm1.SaveButtonClick(Sender: TObject);lastpassword.text= then lastpassword.Text:=;newdoc=false then(f,namer);(f);(f,0);(f,zap);lastpassword.Text<>decode.cipher(zap.password,zap.dlin) then informationlabel.Caption:=Старый пароль неверенbeginnewpassword1.Text=newpassword2.text then(f,0);.password:=code.cipher(newpassword1.text,length(newpassword1.text));.dlin:=length(newpassword1.text);(f,zap);.Text:=;.Text:=;.Text:=;.Caption:=Сохранено;informationlabel.Caption:=Пароли не совпадают;; pswchange:=true;newpassword1.Text=newpassword2.text thenSaveDialog1.Execute then:=SaveDialog1.FileName+.psw;(f,namer);(f);(f,0);.password:=code.cipher(newpassword1.text,length(newpassword1.text));.dlin:=length(newpassword1.text);(f,zap);.Text:=;.Text:=;.Text:=;.Caption:=Сохранено;(f,1);I:=1 to Tablica.RowCount do((Tablica.Cells[0,i]=)(tablica.Cells[1,i]=)(tablica.Cells[4,i]=)) then continuebeginTablica.Cells[0,i]= then zap.flag:=falsezap.flag:=true;.password:=code.cipher(tablica.Cells[1,i], length(tablica.Cells[1,i]));.dlin:=length(tablica.Cells[1,i]);.zamet:=tablica.Cells[4,i];(f,zap);;; endinformationlabel.Caption:=Пароли не совпадают;:=false; pswchange:=false;;TForm1.SecuritybuttonClick(Sender: TObject);.ClientHeight:=509;;TForm1.Button1Click(Sender: TObject);.ClientHeight:=296;;TForm1.FormClose(Sender: TObject; var Action: TCloseAction);PSWChange=true then

case MessageBox(Handle,PChar(Изменения не сохранены. Закрыть без сохранения?),PChar(Внимание),MB_YESNOCANCEL+MB_APPLMODAL) of

IDYES:begin end;: beginSaveDialog1.Execute then:=caNone;:=SaveDialog1.FileName+.psw;(f,namer);(f);(f,0);.password:=;.dlin:=0;(f,zap);(f,1);I:=1 to Tablica.RowCount do((Tablica.Cells[0,i]=)(tablica.Cells[1,i]=)(tablica.Cells[4,i]=)) then continuebeginTablica.Cells[0,i]= then zap.flag:=falsezap.flag:=true;.password:=code.cipher(tablica.Cells[1,i], length(tablica.Cells[1,i]));.dlin:=length(tablica.Cells[1,i]);.zamet:=tablica.Cells[4,i];(f,zap);;; pswchange:=false; newdoc:=true; end;: begin action:=caNone; end;;;;TForm1.FormCreate(Sender: TObject);not FileExists(ExtractFilePath( ParamStr(0) ) + settings.stgg) then begin

showmessage(Нет файла настроек. Убедитесь, что он находится в папке с программой или переустановите её);

0thenbeginPSWChange=truethenMessageBox(Handle,PChar(.?),PChar(Внимание),MB_YESNOCANCEL+MB_APPLMODAL) of:begin end;: beginSaveDialog1.Execute then:=SaveDialog1.FileName+.psw;(f,namer);(f);(f,0);.password:=;.dlin:=0;(f,zap);(f,1);I:=1 to Tablica.RowCount do((Tablica.Cells[0,i]=)(tablica.Cells[1,i]=)(tablica.Cells[4,i]=)) then continuebeginTablica.Cells[0,i]= then zap.flag:=falsezap.flag:=true;.password:=code.cipher(tablica.Cells[1,i], length(tablica.Cells[1,i]));.dlin:=length(tablica.Cells[1,i]);.zamet:=tablica.Cells[4,i];(f,zap);;; pswchange:=false; newdoc:=true; end;: begin exit; end;;; end;.RowCount:=10;i:=1 to Tablica.RowCount do.Rows[i].Clear;.RowCount:=10;i := 1 to Tablica.rowcount do.cells[2,I]:=?;i := 1 to Tablica.rowcount do.cells[3,I]:=d;;TForm1.N3Click(Sender: TObject);pis<>0 then begin if PSWChange=true thenMessageBox(Handle,PChar(Изменения не сохранены. Закрыть без сохранения?),PChar(Внимание),MB_YESNOCANCEL+MB_APPLMODAL) of:begin end;: beginSaveDialog1.Execute then:=SaveDialog1.FileName+.psw;(f,namer);(f);(f,0);.password:=;.dlin:=0;(f,zap);(f,1);I:=1 to Tablica.RowCount do((Tablica.Cells[0,i]=)(tablica.Cells[1,i]=)(tablica.Cells[4,i]=)) then continuebeginTablica.Cells[0,i]= then zap.flag:=falsezap.flag:=true;.password:=code.cipher(tablica.Cells[1,i], length(tablica.Cells[1,i]));.dlin:=length(tablica.Cells[1,i]);.zamet:=tablica.Cells[4,i];(f,zap);;; newdoc:=false; pswchange:=false; end;: begin exit; end;;; end;OpenDialog1.execute then:=OpenDialog1.FileName;(f,namer);(f);(f,0);(f,zap);filesize(f)=1 then tablica.RowCount:=2filesize(f)-1<>Tablica.RowCount thenzap.dlin<>0 then n:=1 else n:=0;.RowCount:=filesize(f);(f,1);i:=1 to filesize(f)-1 do(f,zap);zap.flag=false then tablica.Cells[0,i]:=tablica.Cells[0,i]:=?;n=1 then begin tablica.cells[1,i]:=Ай-ай-ай!; pis:=0; endbegin tablica.cells[1,i]:=decode.cipher(zap.password, zap.dlin); pis:=1; end;.Cells[4,i]:=zap.zamet;;:=false;:=false;;;;TForm1.N4Click(Sender: TObject);pis <>0 then if newdoc=false then begin(f,namer);(f);(f,1);I:=1 to Tablica.RowCount do((Tablica.Cells[0,i]=)(tablica.Cells[1,i]=)(tablica.Cells[4,i]=)) then continuebeginTablica.Cells[0,i]= then zap.flag:=falsezap.flag:=true;.password:=code.cipher(tablica.Cells[1,i], length(tablica.Cells[1,i]));.dlin:=length(tablica.Cells[1,i]);.zamet:=tablica.Cells[4,i];(f,zap);;;if SaveDialog1.Execute