R&Q плагин для шифрования переписки между двумя крысо-клиентами посредством AES 256-bit
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
ratcrypt/setpassform.pas

167 lines
4.9 KiB

unit setpassform;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
StdCtrls, CallExec, IniFiles, Vcl.Buttons, Vcl.Dialogs;
{$I NoRTTI.inc}
type
Tsetpass = class(TForm)
Label1: TLabel;
Edit1: TEdit;
OD: TOpenDialog;
Edit2: TEdit;
Label3: TLabel;
Label2: TLabel;
Label4: TLabel;
Memo1: TMemo;
pass_check: TRadioButton;
file_check: TRadioButton;
SaveBtn: TButton;
OpenKeyFile: TSpeedButton;
procedure SaveBtnClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure OpenKeyFileClick(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
procedure SaveSettings;
procedure LoadSettings;
{ Public declarations }
end;
var
userPath: ansistring;
setpass: Tsetpass;
Global: boolean;
stx: TStringList;
trans_keynotfound: string = 'Ôàéë ñ êëþ÷¸ì íå íàéäåí. Ïðîâåðüòå çàäàííûé ïóòü. Îòïðàâêà îòìåíåíà.';
trans_keynotfound2
: string = 'Ôàéë ñ êëþ÷¸ì íå íàéäåí. Ïðîâåðüòå çàäàííûé ïóòü. Ñîîáùåíèå áóäåò îòîáðàæåíî â íåèçìåí¸ííîì âèäå.';
trans_formtitle: string = 'Íàñòðîéêè øèôðîâàíèÿ';
trans_pass: string = 'Ïàðîëü:';
trans_keyfile: string = 'Ôàéë ñ êëþ÷îì:';
trans_settings: string = 'Íàñòðîéêè';
trans_crypt: string = 'Øèôðîâàòü ïðè îòïðàâêå íà ýòè óèíû:';
trans_use: string = 'Èñïîëüçîâàòü:';
trans_passwd: string = 'Ââåä¸ííûé ïàðîëü';
trans_key: string = 'Ôàéë ñ êëþ÷îì';
trans_crypterr: string = 'Îøèáêà ïðè øèôðîâàíèè ñîîáùåíèÿ, îòïðàâêà îòìåíåíà.';
trans_warn: string = 'Âíèìàíèå';
trans_about: string = 'Î ïëàãèíå';
trans_origmsg: string = '[Îøèáêà ïðè ðàñøèôðîâêå] Îðèãèíàëüíîå ñîîáùåíèå:';
trans_browsefile: string = 'Óêàçàòü ôàéë...';
implementation
{$R *.dfm}
procedure Tsetpass.SaveSettings;
begin
stx := TStringList.create;
if Global = true then
stx.Add('on')
else
stx.Add('off');
if pass_check.Checked = true then
stx.Add('pass_check')
else
stx.Add('file_check');
stx.Add(Edit1.text);
stx.Add(Edit2.text);
stx.SaveToFile(userPath + 'RatCrypt.ini');
stx.Free;
Memo1.lines.SaveToFile(userPath + 'RatCryptWho.ini');
end;
procedure Tsetpass.LoadSettings;
begin
if fileexists(userPath + 'RatCryptWho.ini') then
Memo1.lines.loadfromfile(userPath + 'RatCryptWho.ini');
if not fileexists(userPath + 'RatCrypt.ini') then
exit;
stx := TStringList.create;
stx.loadfromfile(userPath + 'RatCrypt.ini');
if stx[0] = 'on' then
Global := true
else
Global := false;
if stx[1] = 'pass_check' then
pass_check.Checked := true
else
file_check.Checked := true;
Edit1.text := stx[2];
Edit2.text := stx[3];
stx.Free;
end;
procedure Tsetpass.SaveBtnClick(Sender: TObject);
begin
setpass.close;
end;
procedure Tsetpass.FormCreate(Sender: TObject);
var ini: TiniFile;
begin
if fileexists(userPath + 'RatCrypt.lng') then
begin
ini := TiniFile.create(userPath + 'RatCrypt.lng');
trans_keynotfound := ini.ReadString('Translation', 'KeyNotFound', trans_keynotfound);
trans_keynotfound2 := ini.ReadString('Translation', 'KeyNotFound2', trans_keynotfound2);
trans_formtitle := ini.ReadString('Translation', 'FormTitle', trans_formtitle);
trans_pass := ini.ReadString('Translation', 'Pass', trans_pass);
trans_keyfile := ini.ReadString('Translation', 'KeyFile', trans_keyfile);
trans_settings := ini.ReadString('Translation', 'Settings', trans_settings);
trans_crypt := ini.ReadString('Translation', 'Crypt', trans_crypt);
trans_use := ini.ReadString('Translation', 'Use', trans_use);
trans_passwd := ini.ReadString('Translation', 'Passwd', trans_passwd);
trans_key := ini.ReadString('Translation', 'Key', trans_key);
trans_crypterr := ini.ReadString('Translation', 'CryptError', trans_crypterr);
trans_warn := ini.ReadString('Translation', 'Warning', trans_warn);
trans_about := ini.ReadString('Translation', 'AboutPlugin', trans_about);
trans_origmsg := ini.ReadString('Translation', 'OriginalMsgError', trans_origmsg);
trans_browsefile := ini.ReadString('Translation', 'BrowseFile', trans_browsefile);
ini.Free;
end;
setpass.caption := trans_formtitle;
Label1.caption := trans_pass;
Label3.caption := trans_keyfile;
Label2.caption := trans_crypt;
Label4.caption := trans_use;
pass_check.caption := trans_passwd;
file_check.caption := trans_key;
OpenKeyFile.Hint := trans_browsefile;
LoadSettings;
end;
procedure Tsetpass.FormClose(Sender: TObject; var Action: TCloseAction);
begin
SaveSettings;
end;
procedure Tsetpass.OpenKeyFileClick(Sender: TObject);
begin
if OD.Execute then
Edit2.text := OD.FileName;
end;
procedure Tsetpass.FormShow(Sender: TObject);
begin
setpass.caption := trans_formtitle;
end;
end.