231 lines
6.7 KiB
Plaintext
231 lines
6.7 KiB
Plaintext
unit DKessDrmMain;
|
|
|
|
interface
|
|
|
|
uses
|
|
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
|
|
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Tocsg.Controls;
|
|
|
|
type
|
|
TDlgKessDrmMain = class(TForm)
|
|
Label1: TLabel;
|
|
Label2: TLabel;
|
|
Label3: TLabel;
|
|
edInitDir: TEdit;
|
|
edEncPath: TEdit;
|
|
edDecPath: TEdit;
|
|
Label4: TLabel;
|
|
edLicenseKey: TEdit;
|
|
btnDec: TButton;
|
|
Label5: TLabel;
|
|
edSrcPath: TEdit;
|
|
brnEnc: TButton;
|
|
btnIsEnc: TButton;
|
|
procedure btnDecClick(Sender: TObject);
|
|
procedure brnEncClick(Sender: TObject);
|
|
procedure btnIsEncClick(Sender: TObject);
|
|
private
|
|
{ Private declarations }
|
|
MgCtrls_: TManagerInputControlsData;
|
|
public
|
|
{ Public declarations }
|
|
Constructor Create(aOwner: TComponent); override;
|
|
Destructor Destroy; override;
|
|
end;
|
|
|
|
var
|
|
DlgKessDrmMain: TDlgKessDrmMain;
|
|
|
|
implementation
|
|
|
|
uses
|
|
Tocsg.Kess, Tocsg.Path, Tocsg.DateTime, System.DateUtils;
|
|
|
|
{$R *.dfm}
|
|
|
|
Constructor TDlgKessDrmMain.Create(aOwner: TComponent);
|
|
begin
|
|
Inherited Create(aOwner);
|
|
MgCtrls_ := TManagerInputControlsData.Create(CutFileExt(GetRunExePath) + '.ini');
|
|
MgCtrls_.RegInputCtrl(edInitDir);
|
|
MgCtrls_.RegInputCtrl(edLicenseKey);
|
|
MgCtrls_.RegInputCtrl(edSrcPath);
|
|
MgCtrls_.RegInputCtrl(edEncPath);
|
|
MgCtrls_.RegInputCtrl(edDecPath);
|
|
MgCtrls_.Load;
|
|
|
|
if edInitDir.Text = '' then
|
|
edInitDir.Text := GetRunExePathDir;
|
|
|
|
if edLicenseKey.Text = '' then
|
|
edLicenseKey.Text := 'kdnavien';
|
|
end;
|
|
|
|
Destructor TDlgKessDrmMain.Destroy;
|
|
begin
|
|
FreeAndNil(MgCtrls_);
|
|
Inherited;
|
|
end;
|
|
|
|
procedure TDlgKessDrmMain.btnIsEncClick(Sender: TObject);
|
|
var
|
|
dwResult: DWORD;
|
|
begin
|
|
edInitDir.Text := Trim(edInitDir.Text);
|
|
edLicenseKey.Text := Trim(edLicenseKey.Text);
|
|
edEncPath.Text := Trim(edEncPath.Text);
|
|
|
|
if edEncPath.Text = '' then
|
|
begin
|
|
MessageBox(Handle, PChar('"암호화된 파일 저장 경로"를 입력해 주십시오.'), PChar(Caption), MB_ICONWARNING or MB_OK);
|
|
edEncPath.SetFocus;
|
|
exit;
|
|
end;
|
|
|
|
MgCtrls_.Save;
|
|
|
|
dwResult := KCT_Init(edInitDir.Text, edLicenseKey.Text); // 디버그 모드에서는 실패한다 24_1126 09:44:28 kku
|
|
if dwResult <> RESULT_SUCCESS then
|
|
begin
|
|
MessageBox(Handle, PChar(Format('KESS 암호화 모듈 초기화를 실패했습니다.'+#13+#10+
|
|
'KESS 모듈 경로 또는 라이선스 키를 확인해주세요. Error=%x', [dwResult])), PChar(Caption), MB_ICONWARNING or MB_OK);
|
|
exit;
|
|
end;
|
|
|
|
dwResult := KCT_IsEncrypt(edEncPath.Text);
|
|
if dwResult = RESULT_SUCCESS then
|
|
MessageBox(Handle, PChar('암호화된 파일입니다.'), PChar(Caption), MB_ICONINFORMATION or MB_OK)
|
|
else
|
|
MessageBox(Handle, PChar(Format('암호화 확인에 실패 했습니다. Error=%x', [dwResult])), PChar(Caption), MB_ICONWARNING or MB_OK);
|
|
end;
|
|
|
|
procedure TDlgKessDrmMain.brnEncClick(Sender: TObject);
|
|
var
|
|
dwResult: DWORD;
|
|
begin
|
|
edInitDir.Text := Trim(edInitDir.Text);
|
|
edLicenseKey.Text := Trim(edLicenseKey.Text);
|
|
edSrcPath.Text := Trim(edSrcPath.Text);
|
|
edEncPath.Text := Trim(edEncPath.Text);
|
|
|
|
if edInitDir.Text = '' then
|
|
begin
|
|
MessageBox(Handle, PChar('"KESS 모듈 경로"를 입력해 주십시오.'), PChar(Caption), MB_ICONWARNING or MB_OK);
|
|
edInitDir.SetFocus;
|
|
exit;
|
|
end;
|
|
|
|
if edLicenseKey.Text = '' then
|
|
begin
|
|
MessageBox(Handle, PChar('"KESS 라이선스 키"를 입력해 주십시오.'), PChar(Caption), MB_ICONWARNING or MB_OK);
|
|
edLicenseKey.SetFocus;
|
|
exit;
|
|
end;
|
|
|
|
if edSrcPath.Text = '' then
|
|
begin
|
|
MessageBox(Handle, PChar('"암호화 할 파일 경로"를 입력해 주십시오.'), PChar(Caption), MB_ICONWARNING or MB_OK);
|
|
edSrcPath.SetFocus;
|
|
exit;
|
|
end;
|
|
|
|
if not FileExists(edSrcPath.Text) then
|
|
begin
|
|
MessageBox(Handle, PChar('"암호화 할 파일"이 존재하지 않습니다.'), PChar(Caption), MB_ICONWARNING or MB_OK);
|
|
edSrcPath.SetFocus;
|
|
exit;
|
|
end;
|
|
|
|
if edEncPath.Text = '' then
|
|
begin
|
|
MessageBox(Handle, PChar('"암호화된 파일 저장 경로"를 입력해 주십시오.'), PChar(Caption), MB_ICONWARNING or MB_OK);
|
|
edEncPath.SetFocus;
|
|
exit;
|
|
end;
|
|
|
|
MgCtrls_.Save;
|
|
|
|
dwResult := KCT_Init(edInitDir.Text, edLicenseKey.Text); // 디버그 모드에서는 실패한다 24_1126 09:44:28 kku
|
|
if dwResult <> RESULT_SUCCESS then
|
|
begin
|
|
MessageBox(Handle, PChar(Format('KESS 암호화 모듈 초기화를 실패했습니다.'+#13+#10+
|
|
'KESS 모듈 경로 또는 라이선스 키를 확인해주세요. Error=%x', [dwResult])), PChar(Caption), MB_ICONWARNING or MB_OK);
|
|
exit;
|
|
end;
|
|
|
|
dwResult := KCT_Encrypt(edSrcPath.Text, 2, edEncPath.Text);
|
|
if dwResult = RESULT_SUCCESS then
|
|
MessageBox(Handle, PChar('파일이 암호화 되었습니다.'), PChar(Caption), MB_ICONINFORMATION or MB_OK)
|
|
else
|
|
MessageBox(Handle, PChar(Format('암호화에 실패 했습니다. Error=%x', [dwResult])), PChar(Caption), MB_ICONWARNING or MB_OK);
|
|
end;
|
|
|
|
procedure TDlgKessDrmMain.btnDecClick(Sender: TObject);
|
|
var
|
|
dwResult: DWORD;
|
|
s: String;
|
|
dt: TDateTime;
|
|
begin
|
|
dt := Now;
|
|
s := DateTimeToStr(dt) + #13#10 + FormatDateTime('yyyy-MM-dd"T"hh:nn:ss.zzz"Z"', TTimeZone.Local.ToUniversalTime(dt));
|
|
ShowMessage(s);
|
|
exit;
|
|
edInitDir.Text := Trim(edInitDir.Text);
|
|
edLicenseKey.Text := Trim(edLicenseKey.Text);
|
|
edEncPath.Text := Trim(edEncPath.Text);
|
|
edDecPath.Text := Trim(edDecPath.Text);
|
|
|
|
if edInitDir.Text = '' then
|
|
begin
|
|
MessageBox(Handle, PChar('"KESS 모듈 경로"를 입력해 주십시오.'), PChar(Caption), MB_ICONWARNING or MB_OK);
|
|
edInitDir.SetFocus;
|
|
exit;
|
|
end;
|
|
|
|
if edLicenseKey.Text = '' then
|
|
begin
|
|
MessageBox(Handle, PChar('"KESS 라이선스 키"를 입력해 주십시오.'), PChar(Caption), MB_ICONWARNING or MB_OK);
|
|
edLicenseKey.SetFocus;
|
|
exit;
|
|
end;
|
|
|
|
if edEncPath.Text = '' then
|
|
begin
|
|
MessageBox(Handle, PChar('"암호화된 파일 저장 경로"를 입력해 주십시오.'), PChar(Caption), MB_ICONWARNING or MB_OK);
|
|
edEncPath.SetFocus;
|
|
exit;
|
|
end;
|
|
|
|
if not FileExists(edEncPath.Text) then
|
|
begin
|
|
MessageBox(Handle, PChar('"암호화된 파일"이 존재하지 않습니다'), PChar(Caption), MB_ICONWARNING or MB_OK);
|
|
edEncPath.SetFocus;
|
|
exit;
|
|
end;
|
|
|
|
if edDecPath.Text = '' then
|
|
begin
|
|
MessageBox(Handle, PChar('"복호화된 파일 저장 경로"를 입력해 주십시오.'), PChar(Caption), MB_ICONWARNING or MB_OK);
|
|
edDecPath.SetFocus;
|
|
exit;
|
|
end;
|
|
|
|
MgCtrls_.Save;
|
|
|
|
dwResult := KCT_Init(edInitDir.Text, edLicenseKey.Text);
|
|
if dwResult <> RESULT_SUCCESS then
|
|
begin
|
|
MessageBox(Handle, PChar(Format('KESS 암호화 모듈 초기화를 실패했습니다.'+#13+#10+
|
|
'KESS 모듈 경로 또는 라이선스 키를 확인해주세요. Error=%x', [dwResult])), PChar(Caption), MB_ICONWARNING or MB_OK);
|
|
exit;
|
|
end;
|
|
|
|
dwResult := KCT_Decrypt(edEncPath.Text, 2, edDecPath.Text);
|
|
if dwResult = RESULT_SUCCESS then
|
|
MessageBox(Handle, PChar('파일이 복호화 되었습니다.'), PChar(Caption), MB_ICONINFORMATION or MB_OK)
|
|
else
|
|
MessageBox(Handle, PChar(Format('복호화에 실패 했습니다. Error=%x', [dwResult])), PChar(Caption), MB_ICONWARNING or MB_OK);
|
|
end;
|
|
|
|
end.
|