home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 5 Developer's Kit / vb5 dev kit.iso / dev / t2win-32 / _encrypt.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-08-24  |  25.6 KB  |  571 lines

  1. VERSION 4.00
  2. Begin VB.Form frmEncrypt 
  3.    BorderStyle     =   4  'Fixed ToolWindow
  4.    Caption         =   "Encrypt - Decrypt"
  5.    ClientHeight    =   5055
  6.    ClientLeft      =   510
  7.    ClientTop       =   2205
  8.    ClientWidth     =   9705
  9.    Height          =   5460
  10.    Left            =   450
  11.    MaxButton       =   0   'False
  12.    MDIChild        =   -1  'True
  13.    ScaleHeight     =   5055
  14.    ScaleWidth      =   9705
  15.    ShowInTaskbar   =   0   'False
  16.    Top             =   1860
  17.    Width           =   9825
  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             =   720
  28.       Width           =   9540
  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           =   9705
  37.       _Version        =   65536
  38.       _ExtentX        =   17119
  39.       _ExtentY        =   847
  40.       _StockProps     =   15
  41.       ForeColor       =   -2147483640
  42.       BackColor       =   12632256
  43.       Begin VB.ComboBox cmb_Function 
  44.          Height          =   300
  45.          Left            =   1365
  46.          TabIndex        =   2
  47.          Top             =   90
  48.          Width           =   7095
  49.       End
  50.       Begin Threed.SSCommand cmdNP 
  51.          Height          =   300
  52.          Index           =   1
  53.          Left            =   9360
  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            =   8520
  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            =   8835
  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 = 10
  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 TestStringEncrypt
  131.       Case 1
  132.          Call TestFileEncrypt
  133.       Case 2
  134.          Call TestDESencrypt
  135.       Case 3
  136.          Call TestDESencryptFile
  137.       Case 4
  138.          Call TestIDEAencrypt
  139.       Case 5
  140.          Call TestIDEAencryptFile
  141.       Case 6
  142.          Call TestDIAMONDencrypt(DIAMOND_FULL_MODE1)
  143.       Case 7
  144.          Call TestDIAMONDencryptFile(DIAMOND_FULL_MODE1)
  145.       Case 8
  146.          Call TestDIAMONDencrypt(DIAMOND_LITE_MODE1)
  147.       Case 9
  148.          Call TestDIAMONDencryptFile(DIAMOND_LITE_MODE1)
  149.       Case 10
  150.          Call TestDIAMONDencrypt(DIAMOND_FULL_MODE2)
  151.       Case 11
  152.          Call TestDIAMONDencryptFile(DIAMOND_FULL_MODE2)
  153.       Case 12
  154.          Call TestDIAMONDencrypt(DIAMOND_LITE_MODE2)
  155.       Case 13
  156.          Call TestDIAMONDencryptFile(DIAMOND_LITE_MODE2)
  157.       Case 14
  158.          Call TestRUBYencrypt(RUBY_MODE_MINIMUM)
  159.       Case 15
  160.          Call TestRUBYencryptFile(RUBY_MODE_MINIMUM)
  161.       Case 16
  162.          Call TestRUBYencrypt(RUBY_MODE_PORTABLE_SAFE)
  163.       Case 17
  164.          Call TestRUBYencryptFile(RUBY_MODE_PORTABLE_SAFE)
  165.       Case 18
  166.          Call TestRUBYencrypt(RUBY_MODE_FORT_KNOX)
  167.       Case 19
  168.          Call TestRUBYencryptFile(RUBY_MODE_FORT_KNOX)
  169.    End Select
  170.    DoEvents
  171.    Call cEnableFI(mdiT2W.Picture1)
  172. End Sub
  173. Private Sub Form_Activate()
  174.    mdiT2W.Label2.Caption = cInsertBlocks(mdiT2W.Label2.Tag, "" & Iteration)
  175. End Sub
  176. Private Sub Form_Load()
  177.    IsLoaded = False
  178.    Show
  179.    Call sub_Load_Combo(cmb_Function, T2WDirInst + "_encrypt.t2w")
  180.    IsLoaded = True
  181. End Sub
  182. Private Sub SSCommand1_Click()
  183.    Call cmb_Function_Click
  184. End Sub
  185. Private Sub TestFileEncrypt()
  186.    Dim lngResult        As Long
  187.    Dim strResult        As String
  188.    Dim strDisplay       As String
  189.    Dim i                As Integer
  190.    Dim File1            As String
  191.    Dim File2            As String
  192.    Dim File3            As String
  193.    Dim Key              As String
  194.    strResult = ""
  195.    strDisplay = ""
  196.    File1 = T2WFileTest
  197.    File2 = "autoexec.encrypted"
  198.    File3 = "autoexec.decrypted"
  199.    Key = "1234567890"
  200.    For i = ENCRYPT_LEVEL_0 To ENCRYPT_LEVEL_4
  201.       strDisplay = strDisplay & "Encrypt (level " & i & ") '" & File1 & "' with '?' to '" & File2 & "' is " & cFileEncrypt(File1, File2, Key, i) & vbCrLf
  202.       strDisplay = strDisplay & "Decrypt (level " & i & ") '" & File2 & "' with '?' to '" & File3 & "' is " & cFileDecrypt(File2, File3, Key, i) & vbCrLf
  203.       strDisplay = strDisplay & "Compare (ns) '" & File1 & "' with '" & File3 & "' is " & IIf(cCmpFileContents(File1, File3, False) = -1, "same", "not same") & vbCrLf & vbCrLf
  204.    Next i
  205.    txt_Result = strDisplay
  206.    'time the function
  207.    TimerHandle = cTimerOpen()
  208.    TimerStartOk = cTimerStart(TimerHandle)
  209.    For i = 1 To Iteration
  210.       lngResult = cFileEncrypt(File1, File2, Key, ENCRYPT_LEVEL_3)
  211.    Next i
  212.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  213.    TimerCloseOk = cTimerClose(TimerHandle)
  214. End Sub
  215. Public Sub TestStringEncrypt()
  216.    Dim lngResult        As Long
  217.    Dim strResult        As String
  218.    Dim strDisplay       As String
  219.    Dim i                As Integer
  220.    Dim Str1             As String
  221.    Dim Str2             As String
  222.    Dim Key              As String
  223.    strResult = ""
  224.    strDisplay = ""
  225.    Str1 = "T2WIN-32, t2win-32"
  226.    Key = "1234567890"
  227.    For i = ENCRYPT_LEVEL_0 To ENCRYPT_LEVEL_4
  228.       Str2 = cEncrypt(Str1, Key, i)
  229.       strDisplay = strDisplay & "Encrypt (level " & i & ") of [" & Str1 & "] with '?' is [" & cFilterChars(Str2, Chr$(0)) & "]" & vbCrLf
  230.       strDisplay = strDisplay & "Decrypt (level " & i & ") of [" & cFilterChars(Str2, Chr$(0)) & "] with '?' is [" & cDecrypt(Str2, Key, i) & "]" & vbCrLf & vbCrLf
  231.    Next i
  232.    strDisplay = strDisplay & vbCrLf
  233.    Str1 = "Windows 95/NT : Hints and Tips"
  234.    For i = ENCRYPT_LEVEL_0 To ENCRYPT_LEVEL_4
  235.       Str2 = cEncrypt(Str1, Key, i)
  236.       strDisplay = strDisplay & "Encrypt (level " & i & ") of [" & Str1 & "] with '?' is [" & cFilterChars(Str2, Chr$(0)) & "]" & vbCrLf
  237.       strDisplay = strDisplay & "Decrypt (level " & i & ") of [" & cFilterChars(Str2, Chr$(0)) & "] with '?' is [" & cDecrypt(Str2, Key, i) & "]" & vbCrLf & vbCrLf
  238.    Next i
  239.    strDisplay = strDisplay & vbCrLf
  240.    Str1 = "Under the sky, the sun lights"
  241.    For i = ENCRYPT_LEVEL_0 To ENCRYPT_LEVEL_4
  242.       Str2 = cEncrypt(Str1, Key, i)
  243.       strDisplay = strDisplay & "Encrypt (level " & i & ") of [" & Str1 & "] with '?' is [" & cFilterChars(Str2, Chr$(0)) & "]" & vbCrLf
  244.       strDisplay = strDisplay & "Decrypt (level " & i & ") of [" & cFilterChars(Str2, Chr$(0)) & "] with '?' is [" & cDecrypt(Str2, Key, i) & "]" & vbCrLf & vbCrLf
  245.    Next i
  246.    strDisplay = strDisplay & vbCrLf
  247.    txt_Result = strDisplay
  248.    'time the function
  249.    TimerHandle = cTimerOpen()
  250.    TimerStartOk = cTimerStart(TimerHandle)
  251.    For i = 1 To Iteration
  252.       strResult = cEncrypt(Str1, Key, ENCRYPT_LEVEL_3)
  253.    Next i
  254.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  255.    TimerCloseOk = cTimerClose(TimerHandle)
  256. End Sub
  257. Private Sub TestDESencrypt()
  258.    Dim lngResult        As Long
  259.    Dim strResult        As String
  260.    Dim strDisplay       As String
  261.    Dim i                As Integer
  262.    Dim Str1             As String
  263.    Dim Str2             As String
  264.    Dim Key              As String
  265.    strResult = ""
  266.    strDisplay = ""
  267.    Key = "1234567890"
  268.    Str1 = "TIME TO WIN (32-Bit)"
  269.    Str2 = cDESencrypt(Str1, Key)
  270.    strDisplay = strDisplay & "DESencrypt [" & Str1 & "] with '?' is [" & cFilterChars(Str2, Chr$(0)) & "]" & vbCrLf
  271.    strDisplay = strDisplay & "DESdecrypt [" & cFilterChars(Str2, Chr$(0)) & "] with '?' is [" & cDESdecrypt(Str2, Key) & "]" & vbCrLf & vbCrLf
  272.    strDisplay = strDisplay & vbCrLf
  273.    Str1 = "T2WIN-32 a DLL for VB 4.0"
  274.    Str2 = cDESencrypt(Str1, Key)
  275.    strDisplay = strDisplay & "DESencrypt [" & Str1 & "] with '?' is [" & cFilterChars(Str2, Chr$(0)) & "]" & vbCrLf
  276.    strDisplay = strDisplay & "DESdecrypt [" & cFilterChars(Str2, Chr$(0)) & "] with '?' is [" & cDESdecrypt(Str2, Key) & "]" & vbCrLf & vbCrLf
  277.    strDisplay = strDisplay & vbCrLf
  278.    Str1 = "Windows 95/NT : Hints and Tips"
  279.    Str2 = cDESencrypt(Str1, Key)
  280.    strDisplay = strDisplay & "DESencrypt [" & Str1 & "] with '?' is [" & cFilterChars(Str2, Chr$(0)) & "]" & vbCrLf
  281.    strDisplay = strDisplay & "DESdecrypt [" & cFilterChars(Str2, Chr$(0)) & "] with '?' is [" & cDESdecrypt(Str2, Key) & "]" & vbCrLf & vbCrLf
  282.    strDisplay = strDisplay & vbCrLf
  283.    Str1 = "Under the sky, the sun lights"
  284.    Str2 = cDESencrypt(Str1, Key)
  285.    strDisplay = strDisplay & "DESencrypt [" & Str1 & "] with '?' is [" & cFilterChars(Str2, Chr$(0)) & "]" & vbCrLf
  286.    strDisplay = strDisplay & "DESdecrypt [" & cFilterChars(Str2, Chr$(0)) & "] with '?' is [" & cDESdecrypt(Str2, Key) & "]" & vbCrLf & vbCrLf
  287.    strDisplay = strDisplay & vbCrLf
  288.    Str1 = "the fox jump over over the lazy dogs"
  289.    Str2 = cDESencrypt(Str1, Key)
  290.    strDisplay = strDisplay & "DESencrypt [" & Str1 & "] with '?' is [" & cFilterChars(Str2, Chr$(0)) & "]" & vbCrLf
  291.    strDisplay = strDisplay & "DESdecrypt [" & cFilterChars(Str2, Chr$(0)) & "] with '?' is [" & cDESdecrypt(Str2, Key) & "]" & vbCrLf & vbCrLf
  292.    strDisplay = strDisplay & vbCrLf
  293.    txt_Result = strDisplay
  294.    'time the function
  295.    TimerHandle = cTimerOpen()
  296.    TimerStartOk = cTimerStart(TimerHandle)
  297.    For i = 1 To Iteration
  298.       strResult = cDESencrypt(Str1, Key)
  299.    Next i
  300.    strResult = cDESencrypt(strResult, Key)
  301.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  302.    TimerCloseOk = cTimerClose(TimerHandle)
  303. End Sub
  304. Private Sub TestIDEAencrypt()
  305.    Dim lngResult        As Long
  306.    Dim strResult        As String
  307.    Dim strDisplay       As String
  308.    Dim i                As Integer
  309.    Dim Str1             As String
  310.    Dim Str2             As String
  311.    Dim Key              As String
  312.    strResult = ""
  313.    strDisplay = ""
  314.    Key = "1234567890123456"
  315.    Str1 = "TIME TO WIN (32-Bit)"
  316.    Str2 = cIDEAencrypt(Str1, Key)
  317.    strDisplay = strDisplay & "IDEAencrypt [" & Str1 & "] with '?' is [" & cFilterChars(Str2, Chr$(0)) & "]" & vbCrLf
  318.    strDisplay = strDisplay & "IDEAdecrypt [" & cFilterChars(Str2, Chr$(0)) & "] with '?' is [" & cIDEAdecrypt(Str2, Key) & "]" & vbCrLf & vbCrLf
  319.    strDisplay = strDisplay & vbCrLf
  320.    Str1 = "T2WIN-32 a DLL for VB 4.0"
  321.    Str2 = cIDEAencrypt(Str1, Key)
  322.    strDisplay = strDisplay & "IDEAencrypt [" & Str1 & "] with '?' is [" & cFilterChars(Str2, Chr$(0)) & "]" & vbCrLf
  323.    strDisplay = strDisplay & "IDEAdecrypt [" & cFilterChars(Str2, Chr$(0)) & "] with '?' is [" & cIDEAdecrypt(Str2, Key) & "]" & vbCrLf & vbCrLf
  324.    strDisplay = strDisplay & vbCrLf
  325.    Str1 = "Windows 95/NT : Hints and Tips"
  326.    Str2 = cIDEAencrypt(Str1, Key)
  327.    strDisplay = strDisplay & "IDEAencrypt [" & Str1 & "] with '?' is [" & cFilterChars(Str2, Chr$(0)) & "]" & vbCrLf
  328.    strDisplay = strDisplay & "IDEAdecrypt [" & cFilterChars(Str2, Chr$(0)) & "] with '?' is [" & cIDEAdecrypt(Str2, Key) & "]" & vbCrLf & vbCrLf
  329.    strDisplay = strDisplay & vbCrLf
  330.    Str1 = "Under the sky, the sun lights"
  331.    Str2 = cIDEAencrypt(Str1, Key)
  332.    strDisplay = strDisplay & "IDEAencrypt [" & Str1 & "] with '?' is [" & cFilterChars(Str2, Chr$(0)) & "]" & vbCrLf
  333.    strDisplay = strDisplay & "IDEAdecrypt [" & cFilterChars(Str2, Chr$(0)) & "] with '?' is [" & cIDEAdecrypt(Str2, Key) & "]" & vbCrLf & vbCrLf
  334.    strDisplay = strDisplay & vbCrLf
  335.    Str1 = "the fox jump over over the lazy dogs"
  336.    Str2 = cIDEAencrypt(Str1, Key)
  337.    strDisplay = strDisplay & "IDEAencrypt [" & Str1 & "] with '?' is [" & cFilterChars(Str2, Chr$(0)) & "]" & vbCrLf
  338.    strDisplay = strDisplay & "IDEAdecrypt [" & cFilterChars(Str2, Chr$(0)) & "] with '?' is [" & cIDEAdecrypt(Str2, Key) & "]" & vbCrLf & vbCrLf
  339.    strDisplay = strDisplay & vbCrLf
  340.    txt_Result = strDisplay
  341.    'time the function
  342.    TimerHandle = cTimerOpen()
  343.    TimerStartOk = cTimerStart(TimerHandle)
  344.    For i = 1 To Iteration
  345.       strResult = cIDEAencrypt(Str1, Key)
  346.    Next i
  347.    strResult = cIDEAencrypt(strResult, Key)
  348.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  349.    TimerCloseOk = cTimerClose(TimerHandle)
  350. End Sub
  351. Private Sub TestDESencryptFile()
  352.    Dim lngResult        As Long
  353.    Dim strResult        As String
  354.    Dim strDisplay       As String
  355.    Dim i                As Integer
  356.    Dim File1            As String
  357.    Dim File2            As String
  358.    Dim File3            As String
  359.    Dim Key              As String
  360.    strResult = ""
  361.    strDisplay = ""
  362.    File1 = T2WFileTest
  363.    File2 = "autoexec.desencrypted"
  364.    File3 = "autoexec.desdecrypted"
  365.    Key = "1234567890"
  366.    strDisplay = strDisplay & "DESencryptFile '" & File1 & "' with '?' to '" & File2 & "' is " & cDESencryptFile(File1, File2, Key) & vbCrLf
  367.    strDisplay = strDisplay & "DESdecryptFile '" & File2 & "' with '?' to '" & File3 & "' is " & cDESdecryptFile(File2, File3, Key) & vbCrLf
  368.    strDisplay = strDisplay & "Compare (ns) '" & File1 & "' with '" & File3 & "' is " & IIf(cCmpFileContents(File1, File3, False) = -1, "same", "not same") & vbCrLf & vbCrLf
  369.    txt_Result = strDisplay
  370.    'time the function
  371.    TimerHandle = cTimerOpen()
  372.    TimerStartOk = cTimerStart(TimerHandle)
  373.    For i = 1 To Iteration
  374.       lngResult = cDESencryptFile(File1, File2, Key)
  375.    Next i
  376.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  377.    TimerCloseOk = cTimerClose(TimerHandle)
  378. End Sub
  379. Private Sub TestIDEAencryptFile()
  380.    Dim lngResult        As Long
  381.    Dim strResult        As String
  382.    Dim strDisplay       As String
  383.    Dim i                As Integer
  384.    Dim File1            As String
  385.    Dim File2            As String
  386.    Dim File3            As String
  387.    Dim Key              As String
  388.    strResult = ""
  389.    strDisplay = ""
  390.    File1 = T2WFileTest
  391.    File2 = "autoexec.ideaencrypted"
  392.    File3 = "autoexec.ideadecrypted"
  393.    Key = "1234567890123456"
  394.    strDisplay = strDisplay & "IDEAencryptFile '" & File1 & "' with '?' to '" & File2 & "' is " & cIDEAencryptFile(File1, File2, Key) & vbCrLf
  395.    strDisplay = strDisplay & "IDEAdecryptFile '" & File2 & "' with '?' to '" & File3 & "' is " & cIDEAdecryptFile(File2, File3, Key) & vbCrLf
  396.    strDisplay = strDisplay & "Compare (ns) '" & File1 & "' with '" & File3 & "' is " & IIf(cCmpFileContents(File1, File3, False) = -1, "same", "not same") & vbCrLf & vbCrLf
  397.    txt_Result = strDisplay
  398.    'time the function
  399.    TimerHandle = cTimerOpen()
  400.    TimerStartOk = cTimerStart(TimerHandle)
  401.    For i = 1 To Iteration
  402.       lngResult = cIDEAencryptFile(File1, File2, Key)
  403.    Next i
  404.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  405.    TimerCloseOk = cTimerClose(TimerHandle)
  406. End Sub
  407. Private Sub TestDIAMONDencrypt(Mode As Integer)
  408.    Dim lngResult        As Long
  409.    Dim strResult        As String
  410.    Dim strDisplay       As String
  411.    Dim i                As Integer
  412.    Dim Str1             As String
  413.    Dim Str2             As String
  414.    Dim Key              As String
  415.    strResult = ""
  416.    strDisplay = ""
  417.    strDisplay = strDisplay & "DIAMOND " & IIf(((Mode Mod 2) = 1), "Full", "Lite") & " Mode" & IIf(((Mode - 1) / 2) = 0, "1", "2") & vbCrLf & vbCrLf
  418.    Key = "1234567890123456"
  419.    Str1 = "TIME TO WIN (32-Bit)"
  420.    Str2 = cDIAMONDencrypt(Str1, Key, Mode)
  421.    strDisplay = strDisplay & "encrypt [" & Str1 & "] with '?' is [" & cFilterChars(Str2, Chr$(0)) & "]" & vbCrLf
  422.    strDisplay = strDisplay & "decrypt [" & cFilterChars(Str2, Chr$(0)) & "] with '?' is [" & cDIAMONDdecrypt(Str2, Key, Mode) & "]" & vbCrLf
  423.    strDisplay = strDisplay & vbCrLf
  424.    Str1 = "T2WIN-32 a DLL for VB 4.0"
  425.    Str2 = cDIAMONDencrypt(Str1, Key, Mode)
  426.    strDisplay = strDisplay & "encrypt [" & Str1 & "] with '?' is [" & cFilterChars(Str2, Chr$(0)) & "]" & vbCrLf
  427.    strDisplay = strDisplay & "decrypt [" & cFilterChars(Str2, Chr$(0)) & "] with '?' is [" & cDIAMONDdecrypt(Str2, Key, Mode) & "]" & vbCrLf
  428.    strDisplay = strDisplay & vbCrLf
  429.    Str1 = "Under the sky, the sun lights"
  430.    Str2 = cDIAMONDencrypt(Str1, Key, Mode)
  431.    strDisplay = strDisplay & "encrypt [" & Str1 & "] with '?' is [" & cFilterChars(Str2, Chr$(0)) & "]" & vbCrLf
  432.    strDisplay = strDisplay & "decrypt [" & cFilterChars(Str2, Chr$(0)) & "] with '?' is [" & cDIAMONDdecrypt(Str2, Key, Mode) & "]" & vbCrLf
  433.    strDisplay = strDisplay & vbCrLf
  434.    Str1 = "the fox jump over over the lazy dogs"
  435.    Str2 = cDIAMONDencrypt(Str1, Key, Mode)
  436.    strDisplay = strDisplay & "encrypt [" & Str1 & "] with '?' is [" & cFilterChars(Str2, Chr$(0)) & "]" & vbCrLf
  437.    strDisplay = strDisplay & "decrypt [" & cFilterChars(Str2, Chr$(0)) & "] with '?' is [" & cDIAMONDdecrypt(Str2, Key, Mode) & "]" & vbCrLf
  438.    strDisplay = strDisplay & vbCrLf
  439.    txt_Result = strDisplay
  440.    'time the function
  441.    TimerHandle = cTimerOpen()
  442.    TimerStartOk = cTimerStart(TimerHandle)
  443.    For i = 1 To Iteration
  444.       strResult = cDIAMONDencrypt(Str1, Key, Mode)
  445.    Next i
  446.    strResult = cDIAMONDencrypt(strResult, Key, Mode)
  447.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  448.    TimerCloseOk = cTimerClose(TimerHandle)
  449. End Sub
  450. Private Sub TestDIAMONDencryptFile(Mode As Integer)
  451.    Dim lngResult        As Long
  452.    Dim strResult        As String
  453.    Dim strDisplay       As String
  454.    Dim i                As Integer
  455.    Dim File1            As String
  456.    Dim File2            As String
  457.    Dim File3            As String
  458.    Dim Key              As String
  459.    strResult = ""
  460.    strDisplay = ""
  461.    strDisplay = strDisplay & "DIAMOND " & IIf(((Mode Mod 2) = 1), "Full", "Lite") & " Mode" & IIf(((Mode - 1) / 2) = 0, "1", "2") & vbCrLf & vbCrLf
  462.    File1 = T2WFileTest
  463.    File2 = "autoexec.DIAMONDencrypted"
  464.    File3 = "autoexec.DIAMONDdecrypted"
  465.    Key = "1234567890123456"
  466.    strDisplay = strDisplay & "encryptFile '" & File1 & "' with '?' to '" & File2 & "' is " & cDIAMONDencryptFile(File1, File2, Key, Mode) & vbCrLf
  467.    strDisplay = strDisplay & "decryptFile '" & File2 & "' with '?' to '" & File3 & "' is " & cDIAMONDdecryptFile(File2, File3, Key, Mode) & vbCrLf
  468.    strDisplay = strDisplay & "Compare (ns) '" & File1 & "' with '" & File3 & "' is " & IIf(cCmpFileContents(File1, File3, False) = -1, "same", "not same") & vbCrLf & vbCrLf
  469.    txt_Result = strDisplay
  470.    'time the function
  471.    TimerHandle = cTimerOpen()
  472.    TimerStartOk = cTimerStart(TimerHandle)
  473.    For i = 1 To Iteration
  474.       lngResult = cDIAMONDencryptFile(File1, File2, Key, Mode)
  475.    Next i
  476.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  477.    TimerCloseOk = cTimerClose(TimerHandle)
  478. End Sub
  479. Private Sub TestRUBYencrypt(Mode As Integer)
  480.    Dim lngResult        As Long
  481.    Dim strResult        As String
  482.    Dim strDisplay       As String
  483.    Dim i                As Integer
  484.    Dim Str1             As String
  485.    Dim Str2             As String
  486.    Dim Key              As String
  487.    Dim DescMode         As String
  488.    strResult = ""
  489.    strDisplay = ""
  490.    Select Case Mode
  491.       Case RUBY_MODE_MINIMUM: DescMode = "RUBY - minimum"
  492.       Case RUBY_MODE_DESK_LOCK: DescMode = "RUBY - desk lock"
  493.       Case RUBY_MODE_DEAD_BOLT: DescMode = "RUBY - dead bolt"
  494.       Case RUBY_MODE_PORTABLE_SAFE: DescMode = "RUBY - portable safe"
  495.       Case RUBY_MODE_ANCHORED_SAFE: DescMode = "RUBY - anchored safe"
  496.       Case RUBY_MODE_BANK_VAULT: DescMode = "RUBY - bank vault"
  497.       Case RUBY_MODE_FORT_KNOX: DescMode = "RUBY - FORT KNOX"
  498.    End Select
  499.    strDisplay = strDisplay & DescMode & vbCrLf & vbCrLf
  500.    Key = "1234567890123456"
  501.    Str1 = "TIME TO WIN (32-Bit)"
  502.    Str2 = cRUBYencrypt(Str1, Key, Mode)
  503.    strDisplay = strDisplay & "encrypt [" & Str1 & "] with '?' is [" & cFilterChars(Str2, Chr$(0)) & "]" & vbCrLf
  504.    strDisplay = strDisplay & "decrypt [" & cFilterChars(Str2, Chr$(0)) & "] with '?' is [" & cRUBYdecrypt(Str2, Key, Mode) & "]" & vbCrLf
  505.    strDisplay = strDisplay & vbCrLf
  506.    Str1 = "T2WIN-32 a DLL for VB 4.0"
  507.    Str2 = cRUBYencrypt(Str1, Key, Mode)
  508.    strDisplay = strDisplay & "encrypt [" & Str1 & "] with '?' is [" & cFilterChars(Str2, Chr$(0)) & "]" & vbCrLf
  509.    strDisplay = strDisplay & "decrypt [" & cFilterChars(Str2, Chr$(0)) & "] with '?' is [" & cRUBYdecrypt(Str2, Key, Mode) & "]" & vbCrLf
  510.    strDisplay = strDisplay & vbCrLf
  511.    Str1 = "Under the sky, the sun lights"
  512.    Str2 = cRUBYencrypt(Str1, Key, Mode)
  513.    strDisplay = strDisplay & "encrypt [" & Str1 & "] with '?' is [" & cFilterChars(Str2, Chr$(0)) & "]" & vbCrLf
  514.    strDisplay = strDisplay & "decrypt [" & cFilterChars(Str2, Chr$(0)) & "] with '?' is [" & cRUBYdecrypt(Str2, Key, Mode) & "]" & vbCrLf
  515.    strDisplay = strDisplay & vbCrLf
  516.    Str1 = "the fox jump over over the lazy dogs"
  517.    Str2 = cRUBYencrypt(Str1, Key, Mode)
  518.    strDisplay = strDisplay & "encrypt [" & Str1 & "] with '?' is [" & cFilterChars(Str2, Chr$(0)) & "]" & vbCrLf
  519.    strDisplay = strDisplay & "decrypt [" & cFilterChars(Str2, Chr$(0)) & "] with '?' is [" & cRUBYdecrypt(Str2, Key, Mode) & "]" & vbCrLf
  520.    strDisplay = strDisplay & vbCrLf
  521.    txt_Result = strDisplay
  522.    'time the function
  523.    TimerHandle = cTimerOpen()
  524.    TimerStartOk = cTimerStart(TimerHandle)
  525.    For i = 1 To Iteration
  526.       strResult = cRUBYencrypt(Str1, Key, Mode)
  527.    Next i
  528.    strResult = cRUBYencrypt(strResult, Key, Mode)
  529.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  530.    TimerCloseOk = cTimerClose(TimerHandle)
  531. End Sub
  532. Private Sub TestRUBYencryptFile(Mode As Integer)
  533.    Dim lngResult        As Long
  534.    Dim strResult        As String
  535.    Dim strDisplay       As String
  536.    Dim i                As Integer
  537.    Dim File1            As String
  538.    Dim File2            As String
  539.    Dim File3            As String
  540.    Dim Key              As String
  541.    Dim DescMode         As String
  542.    strResult = ""
  543.    strDisplay = ""
  544.    Select Case Mode
  545.       Case RUBY_MODE_MINIMUM: DescMode = "RUBY - minimum"
  546.       Case RUBY_MODE_DESK_LOCK: DescMode = "RUBY - desk lock"
  547.       Case RUBY_MODE_DEAD_BOLT: DescMode = "RUBY - dead bolt"
  548.       Case RUBY_MODE_PORTABLE_SAFE: DescMode = "RUBY - portable safe"
  549.       Case RUBY_MODE_ANCHORED_SAFE: DescMode = "RUBY - anchored safe"
  550.       Case RUBY_MODE_BANK_VAULT: DescMode = "RUBY - bank vault"
  551.       Case RUBY_MODE_FORT_KNOX: DescMode = "RUBY - FORT KNOX"
  552.    End Select
  553.    strDisplay = strDisplay & DescMode & vbCrLf & vbCrLf
  554.    File1 = T2WFileTest
  555.    File2 = "autoexec.RUBYencrypted"
  556.    File3 = "autoexec.RUBYdecrypted"
  557.    Key = "1234567890123456"
  558.    strDisplay = strDisplay & "encryptFile '" & File1 & "' with '?' to '" & File2 & "' is " & cRUBYencryptFile(File1, File2, Key, Mode) & vbCrLf
  559.    strDisplay = strDisplay & "decryptFile '" & File2 & "' with '?' to '" & File3 & "' is " & cRUBYdecryptFile(File2, File3, Key, Mode) & vbCrLf
  560.    strDisplay = strDisplay & "Compare (ns) '" & File1 & "' with '" & File3 & "' is " & IIf(cCmpFileContents(File1, File3, False) = -1, "same", "not same") & vbCrLf & vbCrLf
  561.    txt_Result = strDisplay
  562.    'time the function
  563.    TimerHandle = cTimerOpen()
  564.    TimerStartOk = cTimerStart(TimerHandle)
  565.    For i = 1 To Iteration
  566.       lngResult = cRUBYencryptFile(File1, File2, Key, Mode)
  567.    Next i
  568.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  569.    TimerCloseOk = cTimerClose(TimerHandle)
  570. End Sub
  571.