home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 4 Power Pack / Visual_Basic4_Power_Pack.bin / vb4files / t2win_32 / _encrypt.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-11-20  |  8.1 KB  |  221 lines

  1. VERSION 4.00
  2. Begin VB.Form frmEncrypt 
  3.    BorderStyle     =   4  'Fixed ToolWindow
  4.    Caption         =   "Encrypt - Decrypt"
  5.    ClientHeight    =   4845
  6.    ClientLeft      =   1890
  7.    ClientTop       =   3270
  8.    ClientWidth     =   7485
  9.    Height          =   5250
  10.    Left            =   1830
  11.    MaxButton       =   0   'False
  12.    MDIChild        =   -1  'True
  13.    ScaleHeight     =   4845
  14.    ScaleWidth      =   7485
  15.    ShowInTaskbar   =   0   'False
  16.    Top             =   2925
  17.    Width           =   7605
  18.    Begin VB.TextBox txt_Result 
  19.       BackColor       =   &H00C0C0C0&
  20.       BorderStyle     =   0  'None
  21.       Height          =   4110
  22.       Left            =   105
  23.       Locked          =   -1  'True
  24.       MultiLine       =   -1  'True
  25.       ScrollBars      =   2  'Vertical
  26.       TabIndex        =   0
  27.       Top             =   630
  28.       Width           =   7260
  29.    End
  30.    Begin Threed.SSPanel SSPanel1 
  31.       Align           =   1  'Align Top
  32.       Height          =   480
  33.       Left            =   0
  34.       TabIndex        =   1
  35.       Top             =   0
  36.       Width           =   7485
  37.       _Version        =   65536
  38.       _ExtentX        =   13203
  39.       _ExtentY        =   847
  40.       _StockProps     =   15
  41.       ForeColor       =   -2147483640
  42.       BackColor       =   12632256
  43.       Begin VB.ComboBox cmb_Function 
  44.          Height          =   315
  45.          Left            =   1365
  46.          TabIndex        =   2
  47.          Top             =   90
  48.          Width           =   4785
  49.       End
  50.       Begin Threed.SSCommand cmdNP 
  51.          Height          =   300
  52.          Index           =   1
  53.          Left            =   7140
  54.          TabIndex        =   6
  55.          Top             =   90
  56.          Width           =   255
  57.          _Version        =   65536
  58.          _ExtentX        =   450
  59.          _ExtentY        =   529
  60.          _StockProps     =   78
  61.          Caption         =   ">"
  62.          BevelWidth      =   1
  63.          Font3D          =   3
  64.          RoundedCorners  =   0   'False
  65.          Outline         =   0   'False
  66.       End
  67.       Begin Threed.SSCommand cmdNP 
  68.          Height          =   300
  69.          Index           =   0
  70.          Left            =   6300
  71.          TabIndex        =   5
  72.          Top             =   90
  73.          Width           =   255
  74.          _Version        =   65536
  75.          _ExtentX        =   450
  76.          _ExtentY        =   529
  77.          _StockProps     =   78
  78.          Caption         =   "<"
  79.          BevelWidth      =   1
  80.          Font3D          =   3
  81.          RoundedCorners  =   0   'False
  82.          Outline         =   0   'False
  83.       End
  84.       Begin VB.Label Label2 
  85.          Caption         =   "&Select a function"
  86.          Height          =   255
  87.          Left            =   90
  88.          TabIndex        =   4
  89.          Top             =   120
  90.          Width           =   1275
  91.       End
  92.       Begin Threed.SSCommand SSCommand1 
  93.          Default         =   -1  'True
  94.          Height          =   300
  95.          Left            =   6615
  96.          TabIndex        =   3
  97.          Top             =   90
  98.          Width           =   465
  99.          _Version        =   65536
  100.          _ExtentX        =   820
  101.          _ExtentY        =   529
  102.          _StockProps     =   78
  103.          Caption         =   "&Go"
  104.          BevelWidth      =   1
  105.          RoundedCorners  =   0   'False
  106.          Outline         =   0   'False
  107.       End
  108.    End
  109. Attribute VB_Name = "frmEncrypt"
  110. Attribute VB_Creatable = False
  111. Attribute VB_Exposed = False
  112. Option Explicit
  113. Option Base 1
  114. Private Const Iteration = 25
  115. Dim IsLoaded         As Integer
  116. Dim TimerStartOk     As Integer
  117. Dim TimerCloseOk     As Integer
  118. Dim TimerHandle      As Integer
  119. Dim TimerValue       As Long
  120. Private Sub cmdNP_Click(Index As Integer)
  121.    Call sub_NextPrev(cmb_Function, Index)
  122. End Sub
  123. Private Sub cmb_Function_Click()
  124.    If (IsLoaded = False) Then Exit Sub
  125.    Call cDisableFI(mdiT2W.Picture1)
  126.    txt_Result = ""
  127.    DoEvents
  128.    Select Case cmb_Function.ListIndex
  129.       Case 0
  130.          Call TestFileEncrypt
  131.       Case 1
  132.          Call TestStringEncrypt
  133.    End Select
  134.    DoEvents
  135.    Call cEnableFI(mdiT2W.Picture1)
  136. End Sub
  137. Private Sub Form_Activate()
  138.    mdiT2W.Label2.Caption = cInsertBlocks(mdiT2W.Label2.Tag, "" & Iteration)
  139. End Sub
  140. Private Sub Form_Load()
  141.    IsLoaded = False
  142.    Show
  143.    Call sub_Load_Combo(cmb_Function, T2WDirInst + "_encrypt.t2w")
  144.    IsLoaded = True
  145. End Sub
  146. Private Sub SSCommand1_Click()
  147.    Call cmb_Function_Click
  148. End Sub
  149. Private Sub TestFileEncrypt()
  150.    Dim lngResult        As Long
  151.    Dim strResult        As String
  152.    Dim strDisplay       As String
  153.    Dim i                As Integer
  154.    Dim File1            As String
  155.    Dim File2            As String
  156.    Dim File3            As String
  157.    Dim Key              As String
  158.    strResult = ""
  159.    strDisplay = ""
  160.    File1 = T2WFileTest
  161.    File2 = "autoexec.encrypted"
  162.    File3 = "autoexec.decrypted"
  163.    Key = "1234567890"
  164.    For i = ENCRYPT_LEVEL_0 To ENCRYPT_LEVEL_4
  165.       strDisplay = strDisplay & "Encrypt (level " & i & ") '" & File1 & "' with '?' to '" & File2 & "' is " & cFileEncrypt(File1, File2, Key, i) & vbCrLf
  166.       strDisplay = strDisplay & "Decrypt (level " & i & ") '" & File2 & "' with '?' to '" & File3 & "' is " & cFileDecrypt(File2, File3, Key, i) & vbCrLf
  167.       strDisplay = strDisplay & "Compare (ns) '" & File1 & "' with '" & File3 & "' is " & IIf(cCmpFileContents(File1, File3, False) = -1, "same", "not same") & vbCrLf & vbCrLf
  168.    Next i
  169.    txt_Result = strDisplay
  170.    'time the function
  171.    TimerHandle = cTimerOpen()
  172.    TimerStartOk = cTimerStart(TimerHandle)
  173.    For i = 1 To Iteration
  174.       lngResult = cFileEncrypt(File1, File2, Key, ENCRYPT_LEVEL_3)
  175.    Next i
  176.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  177.    TimerCloseOk = cTimerClose(TimerHandle)
  178. End Sub
  179. Public Sub TestStringEncrypt()
  180.    Dim lngResult        As Long
  181.    Dim strResult        As String
  182.    Dim strDisplay       As String
  183.    Dim i                As Integer
  184.    Dim Str1             As String
  185.    Dim Str2             As String
  186.    Dim Key              As String
  187.    strResult = ""
  188.    strDisplay = ""
  189.    Str1 = "T2WIN-32, t2win-32"
  190.    Key = "1234567890"
  191.    For i = ENCRYPT_LEVEL_0 To ENCRYPT_LEVEL_4
  192.       Str2 = cEncrypt(Str1, Key, i)
  193.       strDisplay = strDisplay & "Encrypt (level " & i & ") of [" & Str1 & "] with '?' is [" & cFilterChars(Str2, Chr$(0)) & "]" & vbCrLf
  194.       strDisplay = strDisplay & "Decrypt (level " & i & ") of [" & cFilterChars(Str2, Chr$(0)) & "] with '?' is [" & cDecrypt(Str2, Key, i) & "]" & vbCrLf & vbCrLf
  195.    Next i
  196.    strDisplay = strDisplay & vbCrLf
  197.    Str1 = "Windows 95 : Hints and Tips"
  198.    For i = ENCRYPT_LEVEL_0 To ENCRYPT_LEVEL_4
  199.       Str2 = cEncrypt(Str1, Key, i)
  200.       strDisplay = strDisplay & "Encrypt (level " & i & ") of [" & Str1 & "] with '?' is [" & cFilterChars(Str2, Chr$(0)) & "]" & vbCrLf
  201.       strDisplay = strDisplay & "Decrypt (level " & i & ") of [" & cFilterChars(Str2, Chr$(0)) & "] with '?' is [" & cDecrypt(Str2, Key, i) & "]" & vbCrLf & vbCrLf
  202.    Next i
  203.    strDisplay = strDisplay & vbCrLf
  204.    Str1 = "Under the sky, the sun lights"
  205.    For i = ENCRYPT_LEVEL_0 To ENCRYPT_LEVEL_4
  206.       Str2 = cEncrypt(Str1, Key, i)
  207.       strDisplay = strDisplay & "Encrypt (level " & i & ") of [" & Str1 & "] with '?' is [" & cFilterChars(Str2, Chr$(0)) & "]" & vbCrLf
  208.       strDisplay = strDisplay & "Decrypt (level " & i & ") of [" & cFilterChars(Str2, Chr$(0)) & "] with '?' is [" & cDecrypt(Str2, Key, i) & "]" & vbCrLf & vbCrLf
  209.    Next i
  210.    strDisplay = strDisplay & vbCrLf
  211.    txt_Result = strDisplay
  212.    'time the function
  213.    TimerHandle = cTimerOpen()
  214.    TimerStartOk = cTimerStart(TimerHandle)
  215.    For i = 1 To Iteration
  216.       strResult = cEncrypt(Str1, Key, ENCRYPT_LEVEL_3)
  217.    Next i
  218.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  219.    TimerCloseOk = cTimerClose(TimerHandle)
  220. End Sub
  221.