home *** CD-ROM | disk | FTP | other *** search
- {
- Xceed Encryption Library - Memory Encryption Sample
- Copyright (c) 2001 Xceed Software Inc
-
- [unOptions.pas]
-
- This unit displays available encryption options
-
- This file is part of the Xceed Encryption Library sample applications.
- The source code in this file is only intended as a supplment to the Xceed
- Encryption Library's documentation and is provided "as is", without warranty
- of any kind either expressed or implied.
- }
-
- unit unOptions;
-
- interface
-
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- StdCtrls, unMemEncrypt, XceedEncryptionLib_TLB;
-
- type
- TfrmOptions = class(TForm)
- Label1 : TLabel;
- Label2 : TLabel;
- Label3 : TLabel;
- Label4 : TLabel;
- Label5 : TLabel;
- cboEncryptionMethod : TComboBox;
- cboEncryptionMode : TComboBox;
- cboKeySize : TComboBox;
- cboHashingMethod : TComboBox;
- cboPaddingMethod : TComboBox;
- btOk : TButton;
- btCancel : TButton;
- procedure FormCreate(Sender: TObject);
- procedure FormDestroy(Sender: TObject);
- procedure btCancelClick(Sender: TObject);
- procedure btOkClick(Sender: TObject);
- private
- m_bOK : boolean;
-
- public
-
- function ShowForm( var eEncryptionMethod : TEncryptionMethod;
- var eEncryptionMode : EXEEncryptionMode;
- var ePaddingMethod : EXEPaddingMethod;
- var eHashingMethod : THashingMethod;
- var lKeySize : integer ) : boolean;
- end;
-
- var
- frmOptions: TfrmOptions;
-
- implementation
-
- {$R *.DFM}
-
- {***************************************************************}
- { }
- { FORM EVENTS }
- { }
- {***************************************************************}
-
- {---------------------------------------------------------------}
- procedure TfrmOptions.FormCreate(Sender: TObject);
- begin
- cboEncryptionMethod.ItemIndex := 0;
- cboEncryptionMode.ItemIndex := 0;
- cboKeySize.ItemIndex := 0;
- cboHashingMethod.ItemIndex := 0;
- cboPaddingMethod.ItemIndex := 0;
- m_bOk := false;
- end;
-
- {---------------------------------------------------------------}
- procedure TfrmOptions.FormDestroy(Sender: TObject);
- begin
- btCancel.Click();
- end;
-
- {---------------------------------------------------------------}
- procedure TfrmOptions.btCancelClick(Sender: TObject);
- begin
- Self.ModalResult := 1;
- Self.Hide();
- end;
-
- {---------------------------------------------------------------}
- procedure TfrmOptions.btOkClick(Sender: TObject);
- begin
- m_bOk := true;
- Self.ModalResult := 1;
- Self.Hide();
- end;
-
- {***************************************************************}
- { }
- { FORM FUNCTIONS AND PROCEDURES }
- { }
- {***************************************************************}
-
- {---------------------------------------------------------------}
- function TfrmOptions.ShowForm( var eEncryptionMethod : TEncryptionMethod;
- var eEncryptionMode : EXEEncryptionMode;
- var ePaddingMethod : EXEPaddingMethod;
- var eHashingMethod : THashingMethod;
- var lKeySize : integer ) : boolean;
- begin
-
- cboEncryptionMethod.ItemIndex := Ord( eEncryptionMethod );
- cboEncryptionMode.ItemIndex := Ord( eEncryptionMode );
- cboPaddingMethod.ItemIndex := Ord( ePaddingMethod );
- cboHashingMethod.ItemIndex := Ord( eHashingMethod );
-
- case lKeySize of
- 128 : cboKeySize.ItemIndex := 0;
- 192 : cboKeySize.ItemIndex := 1;
- 256 : cboKeySize.ItemIndex := 2;
- end;
-
- Self.ShowModal();
-
- if m_bOK then
- begin
- eEncryptionMethod := TEncryptionMethod( cboEncryptionMethod.ItemIndex );
- eEncryptionMode := EXEEncryptionMode( cboEncryptionMode.ItemIndex );
- ePaddingMethod := EXEPaddingMethod ( cboPaddingMethod.ItemIndex );
- eHashingMethod := THashingMethod ( cboHashingMethod.ItemIndex );
-
- case cboKeySize.ItemIndex of
- 0 : lKeySize := 128;
- 1 : lKeySize := 192;
- 2 : lKeySize := 256;
- end;
- end;
- ShowForm := m_bOk;
- Self.Close();
- end;
-
- end.
-