home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 September / Chip_2002-09_cd1.bin / zkuste / vbasic / Data / Utils / XZipComp.exe / XceedEncryption.Cab / F112941_unOptions.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2001-07-04  |  4.5 KB  |  140 lines

  1. {
  2.  Xceed Encryption Library - Encryption Manager sample
  3.  Copyright (c) 2001 Xceed Software Inc.
  4.  
  5.  [unOptions.pas]
  6.  
  7.  This unit displays available encryption options.
  8.  
  9.  This file is part of the Xceed Encryption Library sample applications.
  10.  The source code in this file is only intended as a supplement to the Xceed
  11.  Encryption Library's documentation and is provided "as is" without warranty
  12.  of any kind, either expressed or implied.
  13. }
  14.  
  15.  
  16. unit unOptions;
  17.  
  18. interface
  19.  
  20. uses
  21.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  22.   StdCtrls, unManager, XceedEncryptionLib_TLB;
  23.  
  24. type
  25.   TfrmOptions = class(TForm)
  26.     Label1              : TLabel;
  27.     Label2              : TLabel;
  28.     Label3              : TLabel;
  29.     Label4              : TLabel;
  30.     Label5              : TLabel;
  31.     cboEncryptionMethod : TComboBox;
  32.     cboEncryptionMode   : TComboBox;
  33.     cboKeySize          : TComboBox;
  34.     cboHashingMethod    : TComboBox;
  35.     cboPaddingMethod    : TComboBox;
  36.     btOk                : TButton;
  37.     btCancel            : TButton;
  38.     procedure FormCreate(Sender: TObject);
  39.     procedure FormDestroy(Sender: TObject);
  40.     procedure btCancelClick(Sender: TObject);
  41.     procedure btOkClick(Sender: TObject);
  42.   private
  43.     m_bOk : boolean;
  44.   public
  45.     function ShowForm( var eEncryptionMethod : TEncryptionMethod ;
  46.                        var eEncryptionMode   : EXEEncryptionMode;
  47.                        var ePaddingMethod    : EXEPaddingMethod;
  48.                        var eHashingMethod    : THashingMethod;
  49.                        var nKeySize          : SmallInt ) : boolean;
  50.   end;
  51.  
  52. var
  53.   frmOptions: TfrmOptions;
  54.  
  55. implementation
  56.  
  57. {$R *.DFM}
  58.  
  59. {***************************************************************}
  60. {                                                               }
  61. { FORM EVENTS                                                   }
  62. {                                                               }
  63. {***************************************************************}
  64.  
  65. {---------------------------------------------------------------}
  66. procedure TfrmOptions.FormCreate(Sender: TObject);
  67. begin
  68.   m_bOk := false;
  69.  
  70.   cboEncryptionMethod.ItemIndex := 0;
  71.   cboEncryptionMode.ItemIndex   := 0;
  72.   cboKeySize.ItemIndex          := 0;
  73.   cboHashingMethod.ItemIndex    := 0;
  74.   cboPaddingMethod.ItemIndex    := 0;
  75. end;
  76.  
  77. {---------------------------------------------------------------}
  78. procedure TfrmOptions.FormDestroy(Sender: TObject);
  79. begin
  80.   btCancel.Click();
  81. end;
  82.  
  83. {---------------------------------------------------------------}
  84. procedure TfrmOptions.btCancelClick(Sender: TObject);
  85. begin
  86.   Hide();
  87.   ModalResult := 1;
  88. end;
  89.  
  90. {---------------------------------------------------------------}
  91. procedure TfrmOptions.btOkClick(Sender: TObject);
  92. begin
  93.   m_bOk := true;
  94.   ModalResult := 1;
  95. end;
  96.  
  97. {***************************************************************}
  98. {                                                               }
  99. { FORM FUNCTIONS AND PROCEDURES                                 }
  100. {                                                               }
  101. {***************************************************************}
  102.  
  103. {---------------------------------------------------------------}
  104. function TfrmOptions.ShowForm( var eEncryptionMethod : TEncryptionMethod ;
  105.                                var eEncryptionMode   : EXEEncryptionMode;
  106.                                var ePaddingMethod    : EXEPaddingMethod;
  107.                                var eHashingMethod    : THashingMethod;
  108.                                var nKeySize          : SmallInt ) : boolean;
  109. begin
  110.   cboEncryptionMethod.ItemIndex := Ord( eEncryptionMethod );
  111.   cboEncryptionMode.ItemIndex := Ord( eEncryptionMode );
  112.   cboPaddingMethod.ItemIndex := Ord( ePaddingMethod );
  113.   cboHashingMethod.ItemIndex := Ord( eHashingMethod );
  114.   case nKeySize of
  115.     128 : cboKeySize.ItemIndex := 0;
  116.     192 : cboKeySize.ItemIndex := 1;
  117.     256 : cboKeySize.ItemIndex := 2;
  118.   end;
  119.  
  120.   ShowModal();
  121.  
  122.   if m_bOK then
  123.   begin
  124.     eEncryptionMethod := TEncryptionMethod( cboEncryptionMethod.ItemIndex );
  125.     eEncryptionMode   := EXEEncryptionMode( cboEncryptionMode.ItemIndex );
  126.     ePaddingMethod    := EXEPaddingMethod ( cboPaddingMethod.ItemIndex );
  127.     eHashingMethod    := THashingMethod   ( cboHashingMethod.ItemIndex );
  128.  
  129.     case cboKeySize.ItemIndex of
  130.       0 : nKeySize := 128;
  131.       1 : nKeySize := 192;
  132.       2 : nKeySize := 256;
  133.     end;
  134.   end;
  135.   ShowForm := m_bOk;
  136.   Self.Close();
  137. end;
  138.  
  139. end.
  140.