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

Register 
新用户注册
Search 搜索
首页 
Home Home
Software
Upload

  
'
' ------------------------------------------------------------
' RC4 - CRYPTING AND DECRYPTING - RAPIDQ  ASSEMBLER  FUNCTIONS
' Version 002       Augut 13th, 2004       by Jacques PHILIPPE
' Speed : ~20  MegaBytes  encrypted/second  on  a  DURON  1200
' ------------------------------------------------------------
' Special thanks to Martin Wehner who pointed us to RC4
' See http://groups.yahoo.com/group/rapidq/files/RC4crypt.zip
' ------------------------------------------------------------
' What's New in August 2004 : New ASM code :
' - no need to pass the lenght of strings anymore
' - string can be any kind of strings, declared, immediate, ...
' ------------------------------------------------------------
' -- RC4 DOCUMENTATION --
' -----------------------
' - RC4 uses the same function to Encrypt and to Decrypt : f(fx)) = x
' - The Key is also called the Password.
' - The Table also called the Box is a 256 bytes memory space which
'   is mixed with the Key and then used to Crypt/Decrypt the Datas.
'   (Here we add 2 bytes - [257], [258] - to the box to store variables
'   - i ,j - for Rc4Pipes). So here, the TABLE is 258 bytes long.
' Much more at : http://www.lameindustries.org/tutorials/rc4/index.shtml
' ------------------------------------------------------------
' -- WARNINGS : --
' ----------------
' - CRYPTING WITH KEYS LONGER THAN ?X? IS ILLEGAL IN CERTAIN COUNTRIES
' - EACH ENCRYPTATION OR DECRYPTATION OVERWRITES THE INPUT STRING
' ============================================================
' -- AVAILABLE  FUNCTIONS : --
' ----------------------------
'   Rc4BinStr (Datas As String, Key As String) As Long            ' ASM
'   RC4Init (bytes258Table As String, KEY As String) as Long      ' ASM Only used with RC4Pipes
'   RC4Pipe (bytes258Table As String, Datas As String) As Long    ' ASM RC4Init must be called first
'   RC4File (sPathFileNameIn As String, sPathFileNameOut As String, Key As String, iBitsSizeInByte As Long) As Long ' RQ
'   GetRC4AsmErrorByName (Error As Long) As String                ' RQ
'
' -- RETURNED VALUES FOR ALL FUNCTIONS --
' ---------------------------------------
'   CONST RC4ASM_FINISHED_OK = 0
'   CONST RC4ASM_ERROR_PTR_KEY = 1
'   CONST RC4ASM_ERROR_LEN_KEY = 2
'   CONST RC4ASM_ERROR_PTR_DATAS = 3
'   CONST RC4ASM_ERROR_LEN_DATAS = 4
'   CONST RC4ASM_ERROR_PTR_STABLE = 5
'   CONST RC4ASM_ERROR_FILE_IN_CANT_BE_OPENED = 6
'   CONST RC4ASM_ERROR_CANT_CREATE_FILE_OUT = 7
'   CONST RC4ASM_ERROR_IBITSIZE_IN_RC4FILE_PIPE = 8
'   CONST RC4ASM_ERROR_UNEXPECTED = 255
' ============================================================
' ============================================================
' -- EXAMPLES : --
' ----------------
' $INCLUDE "RC4ASM.Inc"     ' ON TOP OF YOUR CODE, BEFORE EVERYTHING
'                           ' RC4ASM.INC dont need "RapidQ.Inc" file or
'                           ' any directive like $EscapeChars ...to be ON
' ------------------------------------------------------------
' 1 - BINARY STRINGS : RC4 a Binary String Datas with a Binary String Key
' ------------------
'   DefStr sDatas = "The string " & Chr$(0) & "You want to encrypt"             ' May Include NULLCHARS
'   DefStr sKey = "The Key" & Chr$(0) & " with wich Encryption will be made"    ' May Include NULLCHARS
'       ' ENCRYPTATION
'   DefInt iResult = RC4BinStr (sDatas, sKey)
'   If iResult <> 0 Then ShowMessage (GetRC4AsmErrorByName(iResult)):End
'       ' sDatas now contains the encrypted Datas
'       ' DECRYPTATION
'   iResult = RC4BinStr (sDatas, sKey)
'   If iResult <> 0 Then ShowMessage (GetRC4AsmErrorByName(iResult)):End
'       ' sDatas now contains the original Value (encrypted then decrypted)
' ------------------------------------------------------------
' 2 - PIPE  : RC4Pipe to RC4 long files or long strings in bits via a buffer
' --------
'   DefStr sDatas1 = "hgjhg" & Chr$(0) & "jhhj" & Chr$(0) & "gjgh"          ' May Include NULLCHARS
'   DefStr sDatas2 = "zre" & Chr$(0) & "azeazrarar" & Chr$(0) & "ayeyrtert" ' May Include NULLCHARS
'   DefStr sKey = "Your" & Chr$(0) & "Password"                             ' May Include NULLCHARS
'   Dim sTable As string * 258                    ' you must DIM a TABLE of 258 bytes for EACH Pipe
'       ' To encrypt, you must initialise the TABLE with your KEY first
'   If RC4Init (sTable, sKey) <> 0 Then ShowMessage ("ERROR"):End
'       ' Encryptation of two or more consecutive strings
'   If RC4Pipe (sTable, sData1) <> 0 Then ShowMessage ("ERROR"):End
'   ' !!! If you want to merge RC4(sDatas1) and RC4(sDatas2), you CANNOT reinitialise the Table !!!
'   If RC4Pipe (sTable, sData2) <> 0 Then ShowMessage ("ERROR"):End
'   sData1 = sDatas1 + sDatas2   ' sDatas1 is now the encryption of original (sDatas1 + sDatas2)
'       ' To decrypt the result you MUST reinitialise the TABLE with the same KEY
'   If RC4Init (sTable, sKey) <> 0 Then ShowMessage ("ERROR"):End
'   If RC4Pipe (sTable, sData1) <> 0 Then ShowMessage ("ERROR"):End
'       ' Now sDatas1 is the original value of (sDatas1 + sDatas2)
' ------------------------------------------------------------
' 3 - FILES  :  RC4 a file using Pipe. You choose the size of the bits
' ---------     (100000 byte here) the larger the bits the faster it is RC4ed
'    DefStr sKey = "Your" & Chr$(0) & "Password"    ' May Include NULLCHARS
'           ' RC4 by bits of 100000 chars
'    If RC4File (YourPathFileNameIn, YourPathFileNameOut, sKey, 100000) <> 0 _
'                                        Then ShowMessage (GetRC4AsmErrorByName):End
' ============================================================
'
' -- FUNCTIONS DETAILS AND NOTES --
' ---------------------------------
' - Rc4BinStr (Datas As String, Key As String) As Long
'   . ENCRYPT/DECRYPT A BINARY STRING DATAS WITH A BINARY STRING KEY
'   . DATAS and KEY may be Binary Strings : they may include Chr$(0)
'   . RQ Example :
'     iReturn = RC4BinStr (sYourDatas, sYourKEY)
'
' - RC4Init (Table258Bytes As String, KEY As String) as Long      ' Only for Pipes
'   . INITIALISE A TABLE FOR AN RC4Pipe USE
'   . You must create a 258 bytes String TABLE and pass it to RC4Init.
'   . 258 bytes because the ASM Pipe routine stores two variables As Byte
'     there at i=[257] and j=[258] . Key may Contain NULLCHARS (Chr$(0))
'   . RQ Example :
'     Dim sMy258BytesTable As String * 258
'     iReturn = RC4Init (sMy258bytesTable, sYourKEY)
'
' - RC4Pipe (Table258Bytes As String, Datas As String) As Long
'   . ENCRYPT/DECRYPT A STRING SPLITTED IN MULTIPLE BITS
'   . Datas may contain NULLCHARS (Chr$(0))
'   . RC4Init must be called First to initialise the TABLE, only once for
'     all the bits RC4'ed' with RC4Pipe
'   . used to RC4 a long string or a file by splitting them in
'     multiple bits, RC4 the bits and merge the RC4 bits.
'   . you must create a 258 bytes string for each running Pipe and have
'     it initialised by RC4Init one single time and then 'PIPE' all your
'     bits
'   . the bits'size may be different for cryprting than for decrypting
'   . RQ Example :
'     iReturn = RC4Init (sYour258bytesTable, sYourKEY)
'     For Bit = 1 To Last
'         iReturn = RC4Pipe (Your258BytesTable, Data(bit))
'     Next Bit
'   . much more clear with RC4File
'
' - RC4File (sPathFileNameIn As String, sPathFileNameOut As String, _
'                                   Key As String, iBitsSizeInByte As Long) As Long
'   . ENCRYPT/DECRYPT sPathFileNameIn in sPathFilNameOut by splitting
'     sPathFileNameIn in Bits of equal Size = iBitsSize
'   . the KEY may contain NULLCHARS (Chr$(0))
'   . iBitsSize will define the Size of the Bits sent to RC4Pipe
'   . the lenght of the bits to RC4 is set by iBitsSize
'   . the larger the Bits the faster it RC4s
'   . the bits'size may be different for crypting than for decrypting a file
'   . RQ Example :
'     DefStr sKey = "Your" & Chr$(0) & "Password"
'     iReturn = RC4File (YourPathFileNameIn, YourPathFileNameOut, sKey, 100000)
'     If iReturn <> 0 Then ShowMessage (GetRC4AsmErrorByName):End
'
' - GetRC4AsmErrorByName (Error As Long) As String
'   . RETURNS A TEXT STRING FROM THE ERROR NUMBERS RETURNED BY ALL
'     RC4Asm Functions.
'   . RQ Example :
'     ShowMessage (GetRC4AsmErrorByName(RC4File(YourPathFileNameIn, _
'                                           YourPathFileNameOut, sKey, 100000))
' ============================================================
' --- RQ CODE ------------------------------------------------
' ============================================================
' $TYPECHECK ON
' ============================================================
' -- CONSTANTES RETURNED ERROR --
' ----------------------------
     CONST RC4ASM_FINISHED_OK = 0
     CONST RC4ASM_ERROR_PTR_KEY = 1
     CONST RC4ASM_ERROR_LEN_KEY = 2
     CONST RC4ASM_ERROR_PTR_DATAS = 3
     CONST RC4ASM_ERROR_LEN_DATAS = 4
     CONST RC4ASM_ERROR_PTR_STABLE = 5
     CONST RC4ASM_ERROR_FILE_IN_CANT_BE_OPENED = 6
     CONST RC4ASM_ERROR_CANT_CREATE_FILE_OUT = 7
     CONST RC4ASM_ERROR_IBITSIZE_IN_RC4FILE_PIPE = 8
     CONST RC4ASM_ERROR_UNEXPECTED = 255
' ============================================================
' ASM PROCEDURES : RC4BinStr, RC4Init, RC4Pipe
' ============================================================
     $IFNDEF CALL_ASM_PROC_X
      $DEFINE CALL_ASM_PROC_X
      DECLARE FUNCTION CallAsmProc LIB "user32" ALIAS "CallWindowProcA" _
       (Proc AS LONG, A1 AS LONG, A2 AS LONG, A3 AS LONG, A4 AS LONG) AS LONG
     $ENDIF
' ============================================================
' ----- START ASM RC4BinStr -----
     DEFBYTE RC4BinStrArray (0 TO 310) = _
      { _
      &HC8, &H00, &H00, &H00, &H81, &HEC, &H2C, &H01, &H00, &H00,  _
      &H89, &HE8, &H2D, &H2C, &H01, &H00, &H00, &H89, &H45, &HD8,  _
      &H53, &H51, &H52, &H56, &H57, &H8B, &H75, &H08, &H81, &HEE,  _
      &H04, &H00, &H00, &H00, &H8B, &H06, &H89, &H45, &HDC, &H8B,  _
      &H75, &H0C, &H81, &HEE, &H04, &H00, &H00, &H00, &H8B, &H06,  _
      &H89, &H45, &HE0, &H81, &H7D, &H0C, &H00, &H00, &H00, &H00,  _
      &H75, &H0A, &HB8, &H01, &H00, &H00, &H00, &HE9, &HE6, &H00,  _
      &H00, &H00, &H81, &H7D, &HE0, &H00, &H00, &H00, &H00, &H75,  _
      &H0A, &HB8, &H02, &H00, &H00, &H00, &HE9, &HD3, &H00, &H00,  _
      &H00, &H81, &H7D, &H08, &H00, &H00, &H00, &H00, &H75, &H0A,  _
      &HB8, &H03, &H00, &H00, &H00, &HE9, &HC0, &H00, &H00, &H00,  _
      &H81, &H7D, &HDC, &H00, &H00, &H00, &H00, &H75, &H0A, &HB8,  _
      &H04, &H00, &H00, &H00, &HE9, &HAD, &H00, &H00, &H00, &HE8,  _
      &H6A, &H00, &H00, &H00, &HB8, &H00, &H00, &H00, &H00, &HBB,  _
      &H00, &H00, &H00, &H00, &H8B, &H75, &HD8, &H8B, &H7D, &H08,  _
      &HB9, &H00, &H00, &H00, &H00, &HBA, &H00, &H00, &H00, &H00,  _
      &HFE, &HC3, &H02, &H04, &H33, &H8A, &H14, &H33, &H86, &H14,  _
      &H30, &H86, &H14, &H33, &H8A, &H14, &H33, &H02, &H14, &H30,  _
      &H50, &HB8, &H00, &H00, &H00, &H00, &H25, &HFF, &H00, &H00,  _
      &H00, &H8A, &H04, &H32, &H30, &H04, &H39, &H58, &H41, &H3B,  _
      &H4D, &HDC, &H75, &HD4, &HB8, &H00, &H00, &H00, &H00, &HE9,  _
      &H58, &H00, &H00, &H00, &HB8, &H00, &H00, &H00, &H00, &H8B,  _
      &H7D, &HD8, &H88, &H07, &H47, &HFE, &HC0, &H75, &HF9, &HB8,  _
      &H00, &H00, &H00, &H00, &HB8, &H00, &H00, &H00, &H00, &HC3,  _
      &HE8, &HE1, &HFF, &HFF, &HFF, &HB8, &H00, &H00, &H00, &H00,  _
      &HBB, &H00, &H00, &H00, &H00, &HB9, &H00, &H00, &H00, &H00,  _
      &H8B, &H75, &HD8, &H8B, &H7D, &H0C, &HBA, &H00, &H00, &H00,  _
      &H00, &H02, &H04, &H1E, &H39, &H4D, &HE0, &H75, &H05, &HB9,  _
      &H00, &H00, &H00, &H00, &H02, &H04, &H0F, &H8A, &H14, &H30,  _
      &H86, &H14, &H33, &H86, &H14, &H30, &H41, &HFE, &HC3, &H75,  _
      &HE2, &HC3, &H5F, &H5E, &H5A, &H59, &H5B, &HC9, &HC2, &H10,  _
      &H00 _
      }
' ----- END ASM RC4BinStr -----
'
' ----- POINTER to use In CallAsmProc -----
'       A Bit Faster than Calling RC4BinStr
     DEFINT ptrRC4BinStr
     ptrRC4BinStr = VARPTR (RC4BinStrArray(0))
'
' ----- RQ CALL RC4BinStr -----
     FUNCTION RC4BinStr (sDatas AS STRING, sKEY AS STRING) AS LONG
      DEFSTR ssDatas = sDatas
      DEFSTR ssKEY = sKEY
      Result = CallAsmProc (ptrRC4BinStr, VARPTR(ssDatas), VARPTR(ssKEY), 0, 0)
     END FUNCTION
' ============================================================
' ----- START ASM RC4Init -----
     DEFBYTE RC4InitArray (0 TO 187) = _
      { _
      &HC8, &H00, &H00, &H00, &H81, &HEC, &H28, &H00, &H00, &H00,  _
      &H53, &H51, &H52, &H56, &H57, &H8B, &H75, &H0C, &H81, &HEE,  _
      &H04, &H00, &H00, &H00, &H8B, &H06, &H89, &H45, &HD8, &H81,  _
      &H7D, &H08, &H00, &H00, &H00, &H00, &H75, &H0A, &HB8, &H05,  _
      &H00, &H00, &H00, &HE9, &H83, &H00, &H00, &H00, &H81, &H7D,  _
      &H0C, &H00, &H00, &H00, &H00, &H75, &H0A, &HB8, &H01, &H00,  _
      &H00, &H00, &HE9, &H70, &H00, &H00, &H00, &H81, &H7D, &HD8,  _
      &H00, &H00, &H00, &H00, &H75, &H0A, &HB8, &H02, &H00, &H00,  _
      &H00, &HE9, &H5D, &H00, &H00, &H00, &HB8, &H00, &H00, &H00,  _
      &H00, &H8B, &H7D, &H08, &H88, &H07, &H47, &HFE, &HC0, &H75,  _
      &HF9, &HB8, &H00, &H00, &H00, &H00, &HBB, &H00, &H00, &H00,  _
      &H00, &HB9, &H00, &H00, &H00, &H00, &H8B, &H75, &H08, &H8B,  _
      &H7D, &H0C, &HBA, &H00, &H00, &H00, &H00, &H02, &H04, &H1E,  _
      &H39, &H4D, &HD8, &H75, &H05, &HB9, &H00, &H00, &H00, &H00,  _
      &H02, &H04, &H0F, &H8A, &H14, &H30, &H86, &H14, &H33, &H86,  _
      &H14, &H30, &H41, &HFE, &HC3, &H75, &HE2, &H8B, &H7D, &H08,  _
      &HC6, &H87, &H00, &H01, &H00, &H00, &H00, &HC6, &H87, &H01,  _
      &H01, &H00, &H00, &H00, &HB8, &H00, &H00, &H00, &H00, &H5F,  _
      &H5E, &H5A, &H59, &H5B, &HC9, &HC2, &H10, &H00 _
      }
' ----- END ASM RC4Init -----
'
' ----- POINTER to use In CallAsmProc -----
'       A Bit Faster than Calling RC4Init
     DEFINT ptrRC4Init
     ptrRC4Init = VARPTR (RC4InitArray(0))
'
' ----- RQ CALL RC4Init -----
     FUNCTION RC4Init (sTable AS STRING, sKEY AS STRING) AS LONG
      DEFSTR ssTable = sTable
      DEFSTR ssKEY = sKEY
      Result = CallAsmProc (ptrRC4Init, VARPTR(ssTable), VARPTR(ssKEY), 0, 0)
     END FUNCTION
' ============================================================
' ----- START ASM RC4Pipe -----
     DEFBYTE RC4PipeArray (0 TO 195) = _
      { _
      &HC8, &H00, &H00, &H00, &H81, &HEC, &H28, &H00, &H00, &H00,  _
      &H53, &H51, &H52, &H56, &H57, &H8B, &H75, &H0C, &H81, &HEE,  _
      &H04, &H00, &H00, &H00, &H8B, &H06, &H89, &H45, &HD8, &H81,  _
      &H7D, &H0C, &H00, &H00, &H00, &H00, &H75, &H0A, &HB8, &H03,  _
      &H00, &H00, &H00, &HE9, &H8B, &H00, &H00, &H00, &H81, &H7D,  _
      &HD8, &H00, &H00, &H00, &H00, &H75, &H0A, &HB8, &H04, &H00,  _
      &H00, &H00, &HE9, &H78, &H00, &H00, &H00, &H81, &H7D, &H08,  _
      &H00, &H00, &H00, &H00, &H75, &H0A, &HB8, &H05, &H00, &H00,  _
      &H00, &HE9, &H65, &H00, &H00, &H00, &H8B, &H75, &H08, &H8A,  _
      &H9E, &H00, &H01, &H00, &H00, &H81, &HE3, &HFF, &H00, &H00,  _
      &H00, &H8A, &H86, &H01, &H01, &H00, &H00, &H25, &HFF, &H00,  _
      &H00, &H00, &H8B, &H7D, &H0C, &HB9, &H00, &H00, &H00, &H00,  _
      &HBA, &H00, &H00, &H00, &H00, &HFE, &HC3, &H02, &H04, &H33,  _
      &H8A, &H14, &H33, &H86, &H14, &H30, &H86, &H14, &H33, &H8A,  _
      &H14, &H33, &H02, &H14, &H30, &H50, &HB8, &H00, &H00, &H00,  _
      &H00, &H81, &HE2, &HFF, &H00, &H00, &H00, &H8A, &H04, &H32,  _
      &H30, &H04, &H39, &H58, &H41, &H3B, &H4D, &HD8, &H75, &HD3,  _
      &H88, &H9E, &H00, &H01, &H00, &H00, &H88, &H86, &H01, &H01,  _
      &H00, &H00, &HB8, &H00, &H00, &H00, &H00, &H5F, &H5E, &H5A,  _
      &H59, &H5B, &HC9, &HC2, &H10, &H00 _
      }
' ----- END ASM RC4Pipe -----
'
' ----- POINTER to use In CallAsmProc -----
'       A Bit Faster than Calling RC4Pipe
     DEFINT ptrRC4Pipe
     ptrRC4Pipe = VARPTR (RC4PipeArray(0))
'
' ----- RQ CALL RC4Pipe -----
     FUNCTION RC4Pipe (sTable AS STRING, sDatas AS STRING) AS LONG
      DEFSTR ssTable = sTable
      DEFSTR ssDatas = sDatas
      Result = CallAsmProc (ptrRC4Pipe, VARPTR(ssTable), VARPTR(ssDatas), 0, 0)
     END FUNCTION
' ============================================================
' ==== GetRC4AsmErrorByName===================================
'  Returns the Name on an Rc4Asm Error 0 to 7
     FUNCTION GetRC4AsmErrorByName (iError AS LONG) AS STRING
      SELECT CASE iError
      CASE RC4ASM_FINISHED_OK                     ' = 0
       Result = " *** RC4ASM FINISHED_OK *** "
      CASE RC4ASM_ERROR_PTR_KEY                   ' = 1
       Result = " *** RC4ASM ERROR_PTR_KEY *** "
      CASE RC4ASM_ERROR_LEN_KEY                   ' = 2
       Result = " *** RC4ASM ERROR_LEN_KEY *** "
      CASE RC4ASM_ERROR_PTR_DATAS                 ' = 3
       Result = " *** RC4ASM ERROR_PTR_DATAS *** "
      CASE RC4ASM_ERROR_LEN_DATAS                 ' = 4
       Result = " *** RC4ASM ERROR_LEN_DATAS *** "
      CASE RC4ASM_ERROR_PTR_STABLE                ' = 5
       Result = " *** RC4ASM ERROR_PTR_STABLE *** "
      CASE RC4ASM_ERROR_FILE_IN_CANT_BE_OPENED    ' = 6
       Result = " *** RC4ASM ERROR FILE IN CANT BE OPENED ***"
      CASE RC4ASM_ERROR_CANT_CREATE_FILE_OUT      ' = 7
       Result = " *** RC4ASM ERROR CANT CREATE FILE OUT ***"
      CASE RC4ASM_ERROR_IBITSIZE_IN_RC4FILE_PIPE  ' = 8
       Result = " *** RC4ASM ERROR IBITSIZE_IN_RC4FILE_PIPE ***"
      CASE ELSE
       Result = " *** RC4ASM ERRONEOUS ERROR NUMBER :) " & STR$(iError) & " ***"
      END SELECT
     END FUNCTION
' ============================================================
' ==== RC4File ===============================================
' ENCRYPT/DECRYPT sPathFileNameIn in sPathFilNameOut With KEY by splitting
' the file in multiple bits of the same size -except the last bit-. The lenght
' of the bits to RC4 is set iBitsSize
'
     FUNCTION RC4File (PathFileNameIn AS STRING, PathFileNameOut AS STRING, Key AS STRING, iBitsSize AS LONG) AS LONG
      DEFSTR sPathFileNameIn = PathFileNameIn, sPathFileNameOut = PathFileNameOut
      DIM file2Rc4 AS QFILESTREAM
      DIM fileRC4Out AS QFILESTREAM
      DIM sTable AS STRING * 258
      DEFINT iReturn
      DEFINT iFileLengthLeft
      DEFSTR sBits, sTmp
      DEFSTR sKey = KEY
'
      IF iBitsSize < 1 THEN Result = RC4ASM_ERROR_IBITSIZE_IN_RC4FILE_PIPE:EXIT FUNCTION ' = 8
'
      IF file2RC4.OPEN (sPathFileNameIn, 0) <> 0 THEN                ' 0 = fmOpenRead
       IF fileRC4Out.OPEN (sPathFileNameOut, 65535) <> 0 THEN   ' 65535 = fmCreate
        iFileLengthLeft = file2RC4.Size
        file2RC4.Position = 0
            ' Initialise the sTable with the Key
        iReturn = RC4Init (sTable, sKey)
        DO
         IF iReturn = 0 THEN     ' Init OK
          IF iFileLengthLeft >= iBitsSize THEN
           sBits = file2RC4.ReadBinStr (iBitsSize)
           iReturn = RC4Pipe (sTable, sBits)
           IF iReturn <> 0 THEN Result = iReturn:EXIT DO
           fileRC4Out.WriteBinStr (sBits, iBitsSize)
           iFileLengthLeft = iFileLengthLeft - iBitsSize
          ELSE
           sBits = file2RC4.ReadBinStr (iFileLengthLeft)
           iReturn = RC4Pipe (sTable, sBits)
           IF iReturn <> 0 THEN Result = iReturn:EXIT DO
           fileRC4Out.WriteBinStr (sBits, iFileLengthLeft)
           iFileLengthLeft = 0
          END IF
         ELSE                    ' Init Failed
          Result = iReturn
          EXIT DO
         END IF

        LOOP UNTIL iFileLengthLeft = 0
        fileRC4Out.CLOSE
       ELSE
        Result = RC4ASM_ERROR_CANT_CREATE_FILE_OUT  ' = 7
       END IF
       file2RC4.CLOSE
      ELSE
       Result = RC4ASM_ERROR_FILE_IN_CANT_BE_OPENED    ' = 6
       EXIT FUNCTION
      END IF
      IF iFileLengthLeft <= 0 THEN Result = 0
     END FUNCTION
' ============================================================
' $TYPECHECK OFF
'
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Thu 2021-10-21  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2004-08-14 18:00:02