Guidance
指路人
g.yi.org
software / rapidq / Examples / ASM / QRC4Asm / QRc4AsmTest.Bas

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
'
' frmRc4Test    Gui Application
'
' Choose one of the following 5 $include
' -----------------------------
     $INCLUDE "QRC4Asm.Inc"     ' = Type_1b, my choice
'$Include "QRC4Asm_Type_1a.Inc"
'$Include "QRC4Asm_Type_1b.Inc"
'$Include "QRC4Asm_Type_2a.Inc"
'$Include "QRC4Asm_Type_2b.Inc"
' -----------------------------
'
     $ESCAPECHARS ON
     $TYPECHECK ON
     $INCLUDE "RAPIDQ.INC"
'
     DECLARE SUB OnClose_frmRc4Test
     DECLARE SUB OnClic_AnyMenu (Sender AS QMENUITEM)
'
     CREATE frmRc4Test AS QFORM
      Center
      Width = 900
      height = 800
      CAPTION = "frmRc4Test" ' & APP_VERSION
      AutoScroll = False
      OnClose = OnClose_frmRc4Test
      CREATE rchWin AS QRICHEDIT  ' will disply the received datas
       Align = 5
       Font.Name = "courier"
       Font.Size = 8
       Font.COLOR = &H800000
       Width = 200
       Height = 200
       ReadOnly = True
       WordWrap = False
       ScrollBars = ssBoth
       HideSelection = False
       PlainText = True
      END CREATE
     END CREATE
'
' --------------------------------------------------------------------
' New Code API Call that lets RapidQ programs minimize to the task bar
     DECLARE FUNCTION SetWindowLong LIB "user32" ALIAS "SetWindowLongA" (hWnd AS LONG, _
      nIndex AS LONG, dwNewLong AS LONG) AS LONG
'      ----- API Constants and Functions
     CONST GWL_HWNDPARENT = (-8)                   'Minimize to task bar
     CONST HWND_DESKTOP = 0
     setwindowlong(frmRc4Test.handle, GWL_HWNDPARENT, HWND_DESKTOP)
     setwindowlong(application.handle, GWL_HWNDPARENT, frmRc4Test.handle)
' --------------------------------------------------------------------
' *************************************
     frmRc4Test.Show
' *************************************
     DIM fileIn  AS QFILESTREAM
     DIM fileOut AS QFILESTREAM
' ----  KEY  ---------------------------------------------------------------------------------------
     DEFSTR sKey = "My" & CHR$(0) & "Unforgettable" & CHR$(0) & "Key"  ' RC4 Key (also named Password)
' Makes TestString_1 and TestString_2 to be RC4ed (rcfored) (TestString_1 = the 2000 first chars of MP3Format.Html file)
     DEFSTR TestString_1, TestString_2, ResultString
     IF fileIn.OPEN ("MP3Format.Html", fmOpenRead) = 0 THEN SHOWMESSAGE ("Cannot Open RC4Asm.Txt\nI Stop"):END
     TestString_1 = fileIn.ReadBinStr(2000) & "\n\nTHIS TEST CUTS THIS FILE AFTER 2000 Characters" ' not too long
     fileIn.CLOSE
'
     TestString_2 = CHR$(0) & "\n\nA NULLCHAR (CHR$(0)) WAS ADDED JUST BEFORE THIS LINE"
' ----  USEFULL STRINGS  ---------------------------------------------------------------------------
     DEFSTR sUnderLine = "\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" _
      & "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
' ---- DEFINE ONE OF THESE TO TEST  ----------------------------------------------------------------
     $DEFINE RC4ASM_BINARY_STRINGS
'$DEFINE RC4ASM_PIPE
'$DEFINE RC4ASM_FILE
'
' ----  GENERAL NOTE  ------------------------------------------------------------------------------
     rchWin.AddString(  " \n *** TO SHOW YOU THE STRINGS CONTAINING CHR$(0) WE DO A\n\n" _
      & "        ReplaceSubStr$(ResultString, Chr$(0), \"WXW\")  \n\n" _
      & " *** BEFORE TO SHOW THESE STRINGS\n" & sUnderLine)
' --------------------------------------------------------------------------------------------------
     $IFDEF RC4ASM_BINARY_STRINGS
' RC4ASM STRINGS EASY
' -------------------
      ResultString = TestString_1 & TestString_2
      rchWin.AddString("   *** Show ResultString before Crypt : " & sUnderline & REPLACESUBSTR$(ResultString, CHR$(0), "WXW") & sUnderline)
      rchWin.Addstring("   *** RC4 easy Encrypt               : " & GetRC4AsmErrorByName (Rc4BinStr(ResultString, "Nice Password")))
      rchWin.AddString("   *** Show ResultString Crypted      : " & sUnderline & REPLACESUBSTR$(ResultString, CHR$(0), "WXW") & sUnderline)
      rchWin.Addstring("   *** RC4 easy Decrypt               : " & GetRC4AsmErrorByName (Rc4BinStr(ResultString, "Nice Password")))
      rchWin.AddString("   *** Show ResultString Decrypted    : " & sUnderline & REPLACESUBSTR$(ResultString, CHR$(0), "WXW") & sUnderline)
     $ENDIF
' -------------------------------------------------------------------------------------------------
     $IFDEF RC4ASM_PIPE
      DIM sTable AS STRING * 258
      rchWin.Addstring("   *** Pipe Init                      : " & GetRC4AsmErrorByName (Rc4Init(sTable, sKey)))
      rchWin.AddString("   *** Show TestString_1 before Crypt : " & sUnderline & REPLACESUBSTR$(TestString_1, CHR$(0), "WXW") & sUnderline)
      rchWin.Addstring("   *** Pipe Datas TestString_1        : " & GetRC4AsmErrorByName (RC4Pipe(sTable, TestString_1)))
      rchWin.AddString("   *** Show TestString_1 Crypted      : " & sUnderline & REPLACESUBSTR$(TestString_1, CHR$(0), "WXW") & sUnderline)
      rchWin.AddString("   *** Show TestString_2 before Crypt : " & sUnderline & REPLACESUBSTR$(TestString_2, CHR$(0), "WXW") & sUnderline)
      rchWin.Addstring("   *** Pipe Datas TestString_2        : " & GetRC4AsmErrorByName (RC4Pipe(sTable, TestString_2)))
      rchWin.AddString("   *** Show TestString_2 Crypted      : " & sUnderline & REPLACESUBSTR$ (TestString_2, CHR$(0), "WXW") & sUnderline)
      ResultString = TestString_1 & TestString_2 ' TestString_1 and TestString_2 are in crypted form here
      rchWin.AddString("   *** Show ResultString = Crypted(TestString_1) + Crypted(TestString_2) : " & sUnderline & REPLACESUBSTR$(ResultString, CHR$(0), "WXW") & sUnderline)
      rchWin.Addstring("   *** Pipe Init                    : " & GetRC4AsmErrorByName (RC4Init(sTable, sKey)))
      rchWin.Addstring("   *** Pipe Datas sTot              : " & GetRC4AsmErrorByName (RC4Pipe(sTable, ResultString)))
      rchWin.AddString("   *** Show ResultString Decrypted  : " & sUnderline & REPLACESUBSTR$(ResultString, CHR$(0), "WXW") & sUnderline)
     $ENDIF
' -------------------------------------------------------------------------------------------------
     $IFDEF RC4ASM_FILE
      rchWin.Addstring("   *** Crypting File    : " & GetRC4AsmErrorByName (RC4File ("MP3Format.Html", "Mp3Format.HtmlCrypted", sKey, 1000)))
      rchWin.Addstring("   *** DeCrypting File  : " & GetRC4AsmErrorByName (RC4File ("Mp3Format.HtmlCrypted", "Mp3Format.HtmlDecrypted", sKey, 800)))
     $ENDIF
' -------------------------------------------------------------------------------------------------
     rchWin.Addstring ("\n   *** FINISHED ***")
' *************************************
     frmRc4Test.Visible = False
     frmRc4Test.SHOWMODAL
' *************************************
'
     SUB OnClose_frmRc4Test
      Application.Terminate
      END
     END SUB
'
掌柜推荐
 
 
¥289.00 ·
 
 
¥1,080.00 ·
 
 
¥1,380.00 ·
 
 
¥638.00 ·
 
 
¥1,290.00 ·
 
 
¥1,420.00 ·
© Sun 2024-11-24  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2004-08-14 18:00:02