home *** CD-ROM | disk | FTP | other *** search
- {
- Xceed Encryption Library - Encryption Manager 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 supplement 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, unManager, 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 nKeySize : SmallInt ) : boolean;
- end;
-
- var
- frmOptions: TfrmOptions;
-
- implementation
-
- {$R *.DFM}
-
- {***************************************************************}
- { }
- { FORM EVENTS }
- { }
- {***************************************************************}
-
- {---------------------------------------------------------------}
- procedure TfrmOptions.FormCreate(Sender: TObject);
- begin
- m_bOk := false;
-
- cboEncryptionMethod.ItemIndex := 0;
- cboEncryptionMode.ItemIndex := 0;
- cboKeySize.ItemIndex := 0;
- cboHashingMethod.ItemIndex := 0;
- cboPaddingMethod.ItemIndex := 0;
- end;
-
- {---------------------------------------------------------------}
- procedure TfrmOptions.FormDestroy(Sender: TObject);
- begin
- btCancel.Click();
- end;
-
- {---------------------------------------------------------------}
- procedure TfrmOptions.btCancelClick(Sender: TObject);
- begin
- Hide();
- ModalResult := 1;
- end;
-
- {---------------------------------------------------------------}
- procedure TfrmOptions.btOkClick(Sender: TObject);
- begin
- m_bOk := true;
- ModalResult := 1;
- end;
-
- {***************************************************************}
- { }
- { FORM FUNCTIONS AND PROCEDURES }
- { }
- {***************************************************************}
-
- {---------------------------------------------------------------}
- function TfrmOptions.ShowForm( var eEncryptionMethod : TEncryptionMethod ;
- var eEncryptionMode : EXEEncryptionMode;
- var ePaddingMethod : EXEPaddingMethod;
- var eHashingMethod : THashingMethod;
- var nKeySize : SmallInt ) : boolean;
- begin
- cboEncryptionMethod.ItemIndex := Ord( eEncryptionMethod );
- cboEncryptionMode.ItemIndex := Ord( eEncryptionMode );
- cboPaddingMethod.ItemIndex := Ord( ePaddingMethod );
- cboHashingMethod.ItemIndex := Ord( eHashingMethod );
- case nKeySize of
- 128 : cboKeySize.ItemIndex := 0;
- 192 : cboKeySize.ItemIndex := 1;
- 256 : cboKeySize.ItemIndex := 2;
- end;
-
- 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 : nKeySize := 128;
- 1 : nKeySize := 192;
- 2 : nKeySize := 256;
- end;
- end;
- ShowForm := m_bOk;
- Self.Close();
- end;
-
- end.
-