Announcement

Collapse
No announcement yet.

bla

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • bla

    Code:
    #INCLUDE "WIN32API.INC"
    ' Constants FOR md5_Transform routine.
       %S11 = 7
       %S12 = 12
       %S13 = 17
       %S14 = 22
       %S21 = 5
       %S22 = 9
       %S23 = 14
       %S24 = 20
       %S31 = 4
       %S32 = 11
       %S33 = 16
       %S34 = 23
       %S41 = 6
       %S42 = 10
       %S43 = 15
       %S44 = 21
    
       TYPE t_MD5_CTX
            lState( 4 ) AS DWORD 'state (ABCD)
            lCount( 1 ) AS DWORD 'number of bits modulo 2^64 (lsp first)
            bBuf AS ASCIIZ * 64 'input buffer
       END TYPE
    
    
    SUB md5_init( BYREF ctx AS t_MD5_CTX )
    'MD5 initialization. Begins an MD5 operation, writing a new context
         ctx.lCount( 0 ) = 0
         ctx.lCount( 1 ) = 0
        ' Load magic initialization constants.
         ctx.lState( 0 ) = &H67452301
         ctx.lState( 1 ) = &HEFCDAB89
         ctx.lState( 2 ) = &H98BADCFE
         ctx.lState( 3 ) = &H10325476
    END SUB
    
    ' Update context TO reflect the concatenation of another buffer full
    ' of bytes.
    SUB md5_Update( BYREF ctx AS t_MD5_CTX, BYVAL bBuf AS BYTE PTR, BYVAL dwLen AS DWORD )
         LOCAL t AS DWORD
         LOCAL tmp AS DWORD
    
    ' Update bitcount
         t = ctx.lCount( 0 )
         tmp = dwlen
         ! shl tmp , 3
         ctx.lCount( 0 ) = t + tmp '+ md5_shiftLeft(dwLen,3)
    
    
         IF ctx.lCount( 0 ) < t THEN
              INCR ctx.lCount( 1 ) 'carry from low to high
         END IF
    
         tmp = dwlen
         ! shr tmp , 29
         ctx.lCount( 1 ) = ctx.lCount( 1 ) + tmp
         ! shr t , 3
         ! and t ,&H3F
    
        'handle any leading odd-sized chunks
         IF ISTRUE( t ) THEN
              LOCAL p AS BYTE PTR
    
              p = VARPTR( ctx.bBuf )
              p = p + t
              t = 64 - t
              IF dwLen < t THEN
                   CALL MoveMemory( BYVAL p, BYVAL bBuf, dwLen )
                   EXIT SUB
              END IF
              CALL MoveMemory( BYVAL p, BYVAL bBuf, t )
              CALL md5_Transform( ctx, VARPTR( ctx.bBuf ))
              bBuf = bBuf + t
              dwLen = dwLen - t
         END IF
        'Process DATA IN 64-BYTE chunks
         DO WHILE( dwLen > = 64 )
              CALL MoveMemory( BYVAL VARPTR( ctx.bBuf ), BYVAL bBuf, 64 )
              CALL md5_Transform( ctx, VARPTR( ctx.bBuf ))
              bBuf = bBuf + 64
              dwLen = dwLen - 64
         LOOP
        'handle any remaining bytes of data
         CALL MoveMemory( BYVAL VARPTR( ctx.bBuf ), BYVAL bBuf, dwLen )
    END SUB

  • #2
    Code:
    #INCLUDE "WIN32API.INC"
    ' Constants FOR md5_Transform routine.
       %S11 = 7
       %S12 = 12
       %S13 = 17
       %S14 = 22
       %S21 = 5
       %S22 = 9
       %S23 = 14
       %S24 = 20
       %S31 = 4
       %S32 = 11
       %S33 = 16
       %S34 = 23
       %S41 = 6
       %S42 = 10
       %S43 = 15
       %S44 = 21
    
       TYPE t_MD5_CTX
            lState( 4 ) AS DWORD 'state (ABCD)
            lCount( 1 ) AS DWORD 'number of bits modulo 2^64 (lsp first)
            bBuf AS ASCIIZ * 64 'input buffer
       END TYPE
    
    
    SUB md5_init( BYREF ctx AS t_MD5_CTX )
    'MD5 initialization. Begins an MD5 operation, writing a new context
         ctx.lCount( 0 ) = 0
         ctx.lCount( 1 ) = 0
        ' Load magic initialization constants.
         ctx.lState( 0 ) = &H67452301
         ctx.lState( 1 ) = &HEFCDAB89
         ctx.lState( 2 ) = &H98BADCFE
         ctx.lState( 3 ) = &H10325476
    END SUB
    
    ' Update context TO reflect the concatenation of another buffer full
    ' of bytes.
    SUB md5_Update( BYREF ctx AS t_MD5_CTX, BYVAL bBuf AS BYTE PTR, BYVAL dwLen AS DWORD )
         LOCAL t AS DWORD
         LOCAL tmp AS DWORD
    
    ' Update bitcount
         t = ctx.lCount( 0 )
         tmp = dwlen
         ! shl tmp , 3
         ctx.lCount( 0 ) = t + tmp '+ md5_shiftLeft(dwLen,3)
    
    
         IF ctx.lCount( 0 ) < t THEN
              INCR ctx.lCount( 1 ) 'carry from low to high
         END IF
    
         tmp = dwlen
         ! shr tmp , 29
         ctx.lCount( 1 ) = ctx.lCount( 1 ) + tmp
         ! shr t , 3
         ! and t ,&H3F
    
        'handle any leading odd-sized chunks
         IF ISTRUE( t ) THEN
              LOCAL p AS BYTE PTR
    
              p = VARPTR( ctx.bBuf )
              p = p + t
              t = 64 - t
              IF dwLen < t THEN
                   CALL MoveMemory( BYVAL p, BYVAL bBuf, dwLen )
                   EXIT SUB
              END IF
              CALL MoveMemory( BYVAL p, BYVAL bBuf, t )
              CALL md5_Transform( ctx, VARPTR( ctx.bBuf ))
              bBuf = bBuf + t
              dwLen = dwLen - t
         END IF
        'Process DATA IN 64-BYTE chunks
         DO WHILE( dwLen > = 64 )
              CALL MoveMemory( BYVAL VARPTR( ctx.bBuf ), BYVAL bBuf, 64 )
              CALL md5_Transform( ctx, VARPTR( ctx.bBuf ))
              bBuf = bBuf + 64
              dwLen = dwLen - 64
         LOOP
        'handle any remaining bytes of data
         CALL MoveMemory( BYVAL VARPTR( ctx.bBuf ), BYVAL bBuf, dwLen )
    END SUB
    
    ' Final wrapup - pad TO 64-BYTE boundary WITH the BIT pattern
    ' 1 0* (64-BIT count of bits processed, MSB-first)
    SUB md5_Final( BYVAL bDigest AS BYTE PTR, ctx AS t_MD5_CTX )
         LOCAL lCount AS DWORD
         LOCAL tmp AS DWORD
         LOCAL tmp1 AS DWORD
         LOCAL x AS DWORD
         LOCAL p AS BYTE PTR
         LOCAL bBuffer AS BYTE PTR
    
         bBuffer = VARPTR( ctx.bBuf )
        'Compute number of bytes MOD 64
         tmp = ctx.lCount( 0 )
          ! shr tmp , 3
          ! and tmp , &H3F
    
        'lCount=(md5_shiftRight(ctx.lCount(0),3) AND &H3F)
         lCount = tmp
    
        'set the first char of padding to &H80.  This is safe since there is
        'always AT least one BYTE free
         p = VARPTR( ctx.bBuf )
         p = p + lCount
         @p = &H80
         INCR p
        ' Bytes of padding needed TO make 64 bytes
         lCount = 64 - 1 - lCount
        ' Pad out TO 56 MOD 64
         IF lCount < 8 THEN
            'two lots of padding: pad the first block to 64 bytes
           ' CALL FillMemory(p,lCount,0)
              tmp = p
              FOR x = 1 TO lCount
                   POKE BYTE, tmp, 0
                   INCR tmp
              NEXT x
    
              CALL md5_Transform( ctx, VARPTR( ctx.bBuf ))
    
    
              tmp = VARPTR( ctx.bBuf )
              FOR x = 1 TO 56
                   POKE BYTE, tmp, 0
                   INCR tmp
              NEXT x
         ELSE
            'pad block to 56 bytes
    
              tmp = p
              FOR x = 1 TO lCount - 8
                   POKE BYTE, tmp, 0
                   INCR tmp
              NEXT x
         END IF
        'append length IN bits and transform
    
         CALL MoveMemory( BYVAL VARPTR( @bBuffer[56] ), BYVAL VARPTR( ctx.lCount( 0 )), 4 )
         CALL MoveMemory( BYVAL VARPTR( @bBuffer[60] ), BYVAL VARPTR( ctx.lCount( 1 )), 4 )
         CALL md5_Transform( ctx, VARPTR( ctx.bBuf ))
         CALL MoveMemory( BYVAL bDigest, BYVAL VARPTR( ctx.lState( 0 )), 16 )
    
    END SUB
    FUNCTION md5_Digest( BYREF ctx AS t_MD5_CTX ) AS STRING
    'returns the MD5 digest as a hex string
         DIM sHex AS STRING
         DIM szDigest AS ASCIIZ * 16
         DIM bDigest AS BYTE PTR
         DIM sCheck AS STRING
         DIM i AS DWORD
    
         bDigest = VARPTR( szDigest )
         CALL md5_Final( bDigest, ctx )
         IF bDigest < > %NULL THEN
              FOR i = 0 TO 15
                   sHex = sHex + HEX$( @bDigest[i], 2 )
              NEXT
         END IF
    
         FUNCTION = sHex
    END FUNCTION
    SUB md5_readFile( BYREF ctx AS t_MD5_CTX, szFile AS ASCIIZ )
    
    'reads a file and calls md5_Update on the buffer
    'md5_Init() MUST have been called prior to calling
    'this function - call md5_Digest() afterwards to
    'get the fingerprint
         LOCAL hFile AS DWORD
         LOCAL szBuffer AS ASCIIZ * 65536
         LOCAL lBufLen AS DWORD
         LOCAL lLen AS DWORD
         LOCAL lResult AS DWORD
         LOCAL lToRead AS DWORD
         LOCAL lToReadHigh AS DWORD
         LOCAL lpBuffer AS DWORD
    
         lBufLen = SIZEOF( szBuffer )
         lpBuffer = VARPTR( szBuffer )
         hFile = CreateFile( szFile, %GENERIC_READ, %FILE_SHARE_READ, _
         BYVAL %NULL, %OPEN_EXISTING, %FILE_ATTRIBUTE_NORMAL, 0& )
         IF hFile < > %INVALID_HANDLE_VALUE THEN
              lToRead = GetFileSize( hFile, lToReadHigh )
              md5_readFile_loop:
              lResult = ReadFile( hFile, BYVAL lpBuffer, lBufLen, lLen, BYVAL %NULL )
              IF lResult = 0 THEN GOTO md5_readFile_close
              CALL md5_Update( ctx, lpBuffer, lLen )
              lToRead = lToRead - lLen
              IF lToRead = 0 THEN GOTO md5_readFile_close
              GOTO md5_readFile_loop
              md5_readFile_close:
              CALL CloseHandle( hFile )
         END IF
    END SUB
    SUB test()
    
    'implements the Md5 test suite to make sure that the
    'implementation is correct
         DIM ctx AS t_MD5_CTX
         DIM szText AS ASCIIZ * 256
    
         CALL md5_Init( ctx ) 'call md5_Init each time to calculate a new digest
         szText = ""
         CALL md5_Update( ctx, VARPTR( szText ), LEN( szText ))
         ?( "Got:       " + LCASE$( md5_Digest( ctx )))
         ?( "Expected:  d41d8cd98f00b204e9800998ecf8427e" )
         CALL md5_Init( ctx ) 'call md5_Init each time to calculate a new digest
         szText = "a"
         CALL md5_Update( ctx, VARPTR( szText ), LEN( szText ))
         ?( "Got:       " + LCASE$( md5_Digest( ctx )))
         ?( "Expected:  0cc175b9c0f1b6a831c399e269772661" )
         CALL md5_Init( ctx ) 'call md5_Init each time to calculate a new digest
         szText = "abc"
         CALL md5_Update( ctx, VARPTR( szText ), LEN( szText ))
         ?( "Got:       " + LCASE$( md5_Digest( ctx )))
         ?( "Expected:  900150983cd24fb0d6963f7d28e17f72" )
         CALL md5_Init( ctx ) 'call md5_Init each time to calculate a new digest
         szText = "message digest"
         CALL md5_Update( ctx, VARPTR( szText ), LEN( szText ))
         ?( "Got:       " + LCASE$( md5_Digest( ctx )))
         ?( "Expected:  f96b697d7cb7938d525a2f31aaf161d0" )
         CALL md5_Init( ctx ) 'call md5_Init each time to calculate a new digest
         szText = "abcdefghijklmnopqrstuvwxyz"
         CALL md5_Update( ctx, VARPTR( szText ), LEN( szText ))
         ?( "Got:       " + LCASE$( md5_Digest( ctx )))
         ?( "Expected:  c3fcd3d76192e4007dfb496cca67e13b" )
         CALL md5_Init( ctx ) 'call md5_Init each time to calculate a new digest
         szText = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
         CALL md5_Update( ctx, VARPTR( szText ), LEN( szText ))
         ?( "Got:       " + LCASE$( md5_Digest( ctx )))
         ?( "Expected:  d174ab98d277d9f5a5611c2c9f419d9f" )
         CALL md5_Init( ctx ) 'call md5_Init each time to calculate a new digest
         szText = "12345678901234567890123456789012345678901234567890123456789012345678901234567890"
         CALL md5_Update( ctx, VARPTR( szText ), LEN( szText ))
         ?( "Got:       " + LCASE$( md5_Digest( ctx )))
         ?( "Expected:  57edf4a22be3c955ac49da2e2107b67a" )
    
    END SUB
    FUNCTION PBMAIN() AS LONG
         CALL Test()
         CALL testfile()
    
        ? "Done press any key."
           WAITKEY$
    
    END FUNCTION
    SUB testfile()
    LOCAL szText         AS ASCIIZ*256
    LOCAL ctx            AS t_MD5_CTX
    
        CALL md5_Init(ctx) 'call md5_Init each time to calculate a new digest
    
        CALL    md5_readFile(ctx,"C:\temp\u.iso")    '-----------------your test file
    
        CALL md5_Update(ctx,VARPTR(szText),LEN(szText))
    
        ?("MD5= "+LCASE$(md5_Digest(ctx)))
    
    END SUB

    Comment


    • #3
      Code:
      SUB md5_Transform( BYREF ctx AS t_MD5_CTX, BYVAL bBuf AS DWORD PTR )
           #DEBUG CODE OFF
           LOCAL a AS DWORD
           LOCAL b AS DWORD
           LOCAL c AS DWORD
           LOCAL d AS DWORD
      
           a = ctx.lState( 0 )
           b = ctx.lState( 1 )
           c = ctx.lState( 2 )
           d = ctx.lState( 3 )
      
      
           #ALIGN 4
      
           ! mov ecx,b
           ! mov edx,c
           ! and edx,ecx
           ! not ecx
           ! mov eax,d
           ! and ecx,eax
           ! or ecx,edx
           ! mov eax,a
           ! add eax,ecx
           ! add eax,&Hd76aa478
           ! mov ebx,bBuf
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov a,eax
           ! rol eax,%S11
           ! mov a,eax
           ! mov ebx,b
           ! add eax,ebx
           ! mov a,eax
           ! mov ecx,a
           ! mov edx,b
           ! and edx,ecx
           ! not ecx
           ! mov eax,c
           ! and ecx,eax
           ! or ecx,edx
           ! mov eax,d
           ! add eax,ecx
           ! add eax,&He8c7b756
           ! mov ebx,bBuf
           ! add ebx,4
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov d,eax
           ! rol eax,%S12
           ! mov d,eax
           ! mov ebx,a
           ! add eax,ebx
           ! mov d,eax
           ! mov ecx,d
           ! mov edx,a
           ! and edx,ecx
           ! not ecx
           ! mov eax,b
           ! and ecx,eax
           ! or ecx,edx
           ! mov eax,c
           ! add eax,ecx
           ! add eax,&H242070db
           ! mov ebx,bBuf
           ! add ebx,8
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov c,eax
           ! rol eax,%S13
           ! mov c,eax
           ! mov ebx,d
           ! add eax,ebx
           ! mov c,eax
           ! mov ecx,c
           ! mov edx,d
           ! and edx,ecx
           ! not ecx
           ! mov eax,a
           ! and ecx,eax
           ! or ecx,edx
           ! mov eax,b
           ! add eax,ecx
           ! add eax,&Hc1bdceee
           ! mov ebx,bBuf
           ! add ebx,12
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov b,eax
           ! rol eax,%S14
           ! mov b,eax
           ! mov ebx,c
           ! add eax,ebx
           ! mov b,eax
           ! mov ecx,b
           ! mov edx,c
           ! and edx,ecx
           ! not ecx
           ! mov eax,d
           ! and ecx,eax
           ! or ecx,edx
           ! mov eax,a
           ! add eax,ecx
           ! add eax,&Hf57c0faf
           ! mov ebx,bBuf
           ! add ebx,16
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov a,eax
           ! rol eax,%S11
           ! mov a,eax
           ! mov ebx,b
           ! add eax,ebx
           ! mov a,eax
           ! mov ecx,a
           ! mov edx,b
           ! and edx,ecx
           ! not ecx
           ! mov eax,c
           ! and ecx,eax
           ! or ecx,edx
           ! mov eax,d
           ! add eax,ecx
           ! add eax,&H4787c62a
           ! mov ebx,bBuf
           ! add ebx,20
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov d,eax
           ! rol eax,%S12
           ! mov d,eax
           ! mov ebx,a
           ! add eax,ebx
           ! mov d,eax
           ! mov ecx,d
           ! mov edx,a
           ! and edx,ecx
           ! not ecx
           ! mov eax,b
           ! and ecx,eax
           ! or ecx,edx
           ! mov eax,c
           ! add eax,ecx
           ! add eax,&Ha8304613
           ! mov ebx,bBuf
           ! add ebx,24
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov c,eax
           ! rol eax,%S13
           ! mov c,eax
           ! mov ebx,d
           ! add eax,ebx
           ! mov c,eax
           ! mov ecx,c
           ! mov edx,d
           ! and edx,ecx
           ! not ecx
           ! mov eax,a
           ! and ecx,eax
           ! or ecx,edx
           ! mov eax,b
           ! add eax,ecx
           ! add eax,&Hfd469501
           ! mov ebx,bBuf
           ! add ebx,28
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov b,eax
           ! rol eax,%S14
           ! mov b,eax
           ! mov ebx,c
           ! add eax,ebx
           ! mov b,eax
           ! mov ecx,b
           ! mov edx,c
           ! and edx,ecx
           ! not ecx
           ! mov eax,d
           ! and ecx,eax
           ! or ecx,edx
           ! mov eax,a
           ! add eax,ecx
           ! add eax,&H698098d8
           ! mov ebx,bBuf
           ! add ebx,32
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov a,eax
           ! rol eax,%S11
           ! mov a,eax
           ! mov ebx,b
           ! add eax,ebx
           ! mov a,eax
           ! mov ecx,a
           ! mov edx,b
           ! and edx,ecx
           ! not ecx
           ! mov eax,c
           ! and ecx,eax
           ! or ecx,edx
           ! mov eax,d
           ! add eax,ecx
           ! add eax,&H8b44f7af
           ! mov ebx,bBuf
           ! add ebx,36
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov d,eax
           ! rol eax,%S12
           ! mov d,eax
           ! mov ebx,a
           ! add eax,ebx
           ! mov d,eax
           ! mov ecx,d
           ! mov edx,a
           ! and edx,ecx
           ! not ecx
           ! mov eax,b
           ! and ecx,eax
           ! or ecx,edx
           ! mov eax,c
           ! add eax,ecx
           ! add eax,&Hffff5bb1
           ! mov ebx,bBuf
           ! add ebx,40
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov c,eax
           ! rol eax,%S13
           ! mov c,eax
           ! mov ebx,d
           ! add eax,ebx
           ! mov c,eax
           ! mov ecx,c
           ! mov edx,d
           ! and edx,ecx
           ! not ecx
           ! mov eax,a
           ! and ecx,eax
           ! or ecx,edx
           ! mov eax,b
           ! add eax,ecx
           ! add eax,&H895cd7be
           ! mov ebx,bBuf
           ! add ebx,44
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov b,eax
           ! rol eax,%S14
           ! mov b,eax
           ! mov ebx,c
           ! add eax,ebx
           ! mov b,eax
           ! mov ecx,b
           ! mov edx,c
           ! and edx,ecx
           ! not ecx
           ! mov eax,d
           ! and ecx,eax
           ! or ecx,edx
           ! mov eax,a
           ! add eax,ecx
           ! add eax,&H6b901122
           ! mov ebx,bBuf
           ! add ebx,48
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov a,eax
           ! rol eax,%S11
           ! mov a,eax
           ! mov ebx,b
           ! add eax,ebx
           ! mov a,eax
           ! mov ecx,a
           ! mov edx,b
           ! and edx,ecx
           ! not ecx
           ! mov eax,c
           ! and ecx,eax
           ! or ecx,edx
           ! mov eax,d
           ! add eax,ecx
           ! add eax,&Hfd987193
           ! mov ebx,bBuf
           ! add ebx,52
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov d,eax
           ! rol eax,%S12
           ! mov d,eax
           ! mov ebx,a
           ! add eax,ebx
           ! mov d,eax
           ! mov ecx,d
           ! mov edx,a
           ! and edx,ecx
           ! not ecx
           ! mov eax,b
           ! and ecx,eax
           ! or ecx,edx
           ! mov eax,c
           ! add eax,ecx
           ! add eax,&Ha679438e
           ! mov ebx,bBuf
           ! add ebx,56
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov c,eax
           ! rol eax,%S13
           ! mov c,eax
           ! mov ebx,d
           ! add eax,ebx
           ! mov c,eax
           ! mov ecx,c
           ! mov edx,d
           ! and edx,ecx
           ! not ecx
           ! mov eax,a
           ! and ecx,eax
           ! or ecx,edx
           ! mov eax,b
           ! add eax,ecx
           ! add eax,&H49b40821
           ! mov ebx,bBuf
           ! add ebx,60
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov b,eax
           ! rol eax,%S14
           ! mov b,eax
           ! mov ebx,c
           ! add eax,ebx
           ! mov b,eax
           ! mov ecx,d
           ! mov edx,b
           ! and edx,ecx
           ! not ecx
           ! mov eax,c
           ! and ecx,eax
           ! or ecx,edx
           ! mov eax,a
           ! add eax,ecx
           ! add eax,&Hf61e2562
           ! mov ebx,bBuf
           ! add ebx,4
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov a,eax
           ! rol eax,%S21
           ! mov a,eax
           ! mov ebx,b
           ! add eax,ebx
           ! mov a,eax
           ! mov ecx,c
           ! mov edx,a
           ! and edx,ecx
           ! not ecx
           ! mov eax,b
           ! and ecx,eax
           ! or ecx,edx
           ! mov eax,d
           ! add eax,ecx
           ! add eax,&Hc040b340
           ! mov ebx,bBuf
           ! add ebx,24
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov d,eax
           ! rol eax,%S22
           ! mov d,eax
           ! mov ebx,a
           ! add eax,ebx
           ! mov d,eax
           ! mov ecx,b
           ! mov edx,d
           ! and edx,ecx
           ! not ecx
           ! mov eax,a
           ! and ecx,eax
           ! or ecx,edx
           ! mov eax,c
           ! add eax,ecx
           ! add eax,&H265e5a51
           ! mov ebx,bBuf
           ! add ebx,44
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov c,eax
           ! rol eax,%S23
           ! mov c,eax
           ! mov ebx,d
           ! add eax,ebx
           ! mov c,eax
           ! mov ecx,a
           ! mov edx,c
           ! and edx,ecx
           ! not ecx
           ! mov eax,d
           ! and ecx,eax
           ! or ecx,edx
           ! mov eax,b
           ! add eax,ecx
           ! add eax,&He9b6c7aa
           ! mov ebx,bBuf
           ! add ebx,0
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov b,eax
           ! rol eax,%S24
           ! mov b,eax
           ! mov ebx,c
           ! add eax,ebx
           ! mov b,eax
           ! mov ecx,d
           ! mov edx,b
           ! and edx,ecx
           ! not ecx
           ! mov eax,c
           ! and ecx,eax
           ! or ecx,edx
           ! mov eax,a
           ! add eax,ecx
           ! add eax,&Hd62f105d
           ! mov ebx,bBuf
           ! add ebx,20
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov a,eax
           ! rol eax,%S21
           ! mov a,eax
           ! mov ebx,b
           ! add eax,ebx
           ! mov a,eax
           ! mov ecx,c
           ! mov edx,a
           ! and edx,ecx
           ! not ecx
           ! mov eax,b
           ! and ecx,eax
           ! or ecx,edx
           ! mov eax,d
           ! add eax,ecx
           ! add eax,&H2441453
           ! mov ebx,bBuf
           ! add ebx,40
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov d,eax
           ! rol eax,%S22
           ! mov d,eax
           ! mov ebx,a
           ! add eax,ebx
           ! mov d,eax
           ! mov ecx,b
           ! mov edx,d
           ! and edx,ecx
           ! not ecx
           ! mov eax,a
           ! and ecx,eax
           ! or ecx,edx
           ! mov eax,c
           ! add eax,ecx
           ! add eax,&Hd8a1e681
           ! mov ebx,bBuf
           ! add ebx,60
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov c,eax
           ! rol eax,%S23
           ! mov c,eax
           ! mov ebx,d
           ! add eax,ebx
           ! mov c,eax
           ! mov ecx,a
           ! mov edx,c
           ! and edx,ecx
           ! not ecx
           ! mov eax,d
           ! and ecx,eax
           ! or ecx,edx
           ! mov eax,b
           ! add eax,ecx
           ! add eax,&He7d3fbc8
           ! mov ebx,bBuf
           ! add ebx,16
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov b,eax
           ! rol eax,%S24
           ! mov b,eax
           ! mov ebx,c
           ! add eax,ebx
           ! mov b,eax
           ! mov ecx,d
           ! mov edx,b
           ! and edx,ecx
           ! not ecx
           ! mov eax,c
           ! and ecx,eax
           ! or ecx,edx
           ! mov eax,a
           ! add eax,ecx
           ! add eax,&H21e1cde6
           ! mov ebx,bBuf
           ! add ebx,36
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov a,eax
           ! rol eax,%S21
           ! mov a,eax
           ! mov ebx,b
           ! add eax,ebx
           ! mov a,eax
           ! mov ecx,c
           ! mov edx,a
           ! and edx,ecx
           ! not ecx
           ! mov eax,b
           ! and ecx,eax
           ! or ecx,edx
           ! mov eax,d
           ! add eax,ecx
           ! add eax,&Hc33707d6
           ! mov ebx,bBuf
           ! add ebx,56
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov d,eax
           ! rol eax,%S22
           ! mov d,eax
           ! mov ebx,a
           ! add eax,ebx
           ! mov d,eax
           ! mov ecx,b
           ! mov edx,d
           ! and edx,ecx
           ! not ecx
           ! mov eax,a
           ! and ecx,eax
           ! or ecx,edx
           ! mov eax,c
           ! add eax,ecx
           ! add eax,&Hf4d50d87
           ! mov ebx,bBuf
           ! add ebx,12
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov c,eax
           ! rol eax,%S23
           ! mov c,eax
           ! mov ebx,d
           ! add eax,ebx
           ! mov c,eax
           ! mov ecx,a
           ! mov edx,c
           ! and edx,ecx
           ! not ecx
           ! mov eax,d
           ! and ecx,eax
           ! or ecx,edx
           ! mov eax,b
           ! add eax,ecx
           ! add eax,&H455a14ed
           ! mov ebx,bBuf
           ! add ebx,32
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov b,eax
           ! rol eax,%S24
           ! mov b,eax
           ! mov ebx,c
           ! add eax,ebx
           ! mov b,eax
           ! mov ecx,d
           ! mov edx,b
           ! and edx,ecx
           ! not ecx
           ! mov eax,c
           ! and ecx,eax
           ! or ecx,edx
           ! mov eax,a
           ! add eax,ecx
           ! add eax,&Ha9e3e905
           ! mov ebx,bBuf
           ! add ebx,52
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov a,eax
           ! rol eax,%S21
           ! mov a,eax
           ! mov ebx,b
           ! add eax,ebx
           ! mov a,eax
           ! mov ecx,c
           ! mov edx,a
           ! and edx,ecx
           ! not ecx
           ! mov eax,b
           ! and ecx,eax
           ! or ecx,edx
           ! mov eax,d
           ! add eax,ecx
           ! add eax,&Hfcefa3f8
           ! mov ebx,bBuf
           ! add ebx,8
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov d,eax
           ! rol eax,%S22
           ! mov d,eax
           ! mov ebx,a
           ! add eax,ebx
           ! mov d,eax
           ! mov ecx,b
           ! mov edx,d
           ! and edx,ecx
           ! not ecx
           ! mov eax,a
           ! and ecx,eax
           ! or ecx,edx
           ! mov eax,c
           ! add eax,ecx
           ! add eax,&H676f02d9
           ! mov ebx,bBuf
           ! add ebx,28
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov c,eax
           ! rol eax,%S23
           ! mov c,eax
           ! mov ebx,d
           ! add eax,ebx
           ! mov c,eax
           ! mov ecx,a
           ! mov edx,c
           ! and edx,ecx
           ! not ecx
           ! mov eax,d
           ! and ecx,eax
           ! or ecx,edx
           ! mov eax,b
           ! add eax,ecx
           ! add eax,&H8d2a4c8a
           ! mov ebx,bBuf
           ! add ebx,48
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov b,eax
           ! rol eax,%S24
           ! mov b,eax
           ! mov ebx,c
           ! add eax,ebx
           ! mov b,eax
           ! mov eax,b
           ! mov edx,c
           ! xor eax,edx
           ! xor eax,d
           ! add eax,a
           ! add eax,&Hfffa3942
           ! mov ebx,bBuf
           ! add ebx,20
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov a,eax
           ! rol eax,%S31
           ! mov a,eax
           ! mov ebx,b
           ! add eax,ebx
           ! mov a,eax
           ! mov eax,a
           ! mov edx,b
           ! xor eax,edx
           ! xor eax,c
           ! add eax,d
           ! add eax,&H8771f681
           ! mov ebx,bBuf
           ! add ebx,32
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov d,eax
           ! rol eax,%S32
           ! mov d,eax
           ! mov ebx,a
           ! add eax,ebx
           ! mov d,eax
           ! mov eax,d
           ! mov edx,a
           ! xor eax,edx
           ! xor eax,b
           ! add eax,c
           ! add eax,&H6d9d6122
           ! mov ebx,bBuf
           ! add ebx,44
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov c,eax
           ! rol eax,%S33
           ! mov c,eax
           ! mov ebx,d
           ! add eax,ebx
           ! mov c,eax
           ! mov eax,c
           ! mov edx,d
           ! xor eax,edx
           ! xor eax,a
           ! add eax,b
           ! add eax,&Hfde5380c
           ! mov ebx,bBuf
           ! add ebx,56
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov b,eax
           ! rol eax,%S34
           ! mov b,eax
           ! mov ebx,c
           ! add eax,ebx
           ! mov b,eax
           ! mov eax,b
           ! mov edx,c
           ! xor eax,edx
           ! xor eax,d
           ! add eax,a
           ! add eax,&Ha4beea44
           ! mov ebx,bBuf
           ! add ebx,4
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov a,eax
           ! rol eax,%S31
           ! mov a,eax
           ! mov ebx,b
           ! add eax,ebx
           ! mov a,eax
           ! mov eax,a
           ! mov edx,b
           ! xor eax,edx
           ! xor eax,c
           ! add eax,d
           ! add eax,&H4bdecfa9
           ! mov ebx,bBuf
           ! add ebx,16
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov d,eax
           ! rol eax,%S32
           ! mov d,eax
           ! mov ebx,a
           ! add eax,ebx
           ! mov d,eax
           ! mov eax,d
           ! mov edx,a
           ! xor eax,edx
           ! xor eax,b
           ! add eax,c
           ! add eax,&Hf6bb4b60
           ! mov ebx,bBuf
           ! add ebx,28
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov c,eax
           ! rol eax,%S33
           ! mov c,eax
           ! mov ebx,d
           ! add eax,ebx
           ! mov c,eax
           ! mov eax,c
           ! mov edx,d
           ! xor eax,edx
           ! xor eax,a
           ! add eax,b
           ! add eax,&Hbebfbc70
           ! mov ebx,bBuf
           ! add ebx,40
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov b,eax
           ! rol eax,%S34
           ! mov b,eax
           ! mov ebx,c
           ! add eax,ebx
           ! mov b,eax
           ! mov eax,b
           ! mov edx,c
           ! xor eax,edx
           ! xor eax,d
           ! add eax,a
           ! add eax,&H289b7ec6
           ! mov ebx,bBuf
           ! add ebx,52
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov a,eax
           ! rol eax,%S31
           ! mov a,eax
           ! mov ebx,b
           ! add eax,ebx
           ! mov a,eax
           ! mov eax,a
           ! mov edx,b
           ! xor eax,edx
           ! xor eax,c
           ! add eax,d
           ! add eax,&Heaa127fa
           ! mov ebx,bBuf
           ! add ebx,0
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov d,eax
           ! rol eax,%S32
           ! mov d,eax
           ! mov ebx,a
           ! add eax,ebx
           ! mov d,eax
           ! mov eax,d
           ! mov edx,a
           ! xor eax,edx
           ! xor eax,b
           ! add eax,c
           ! add eax,&Hd4ef3085
           ! mov ebx,bBuf
           ! add ebx,12
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov c,eax
           ! rol eax,%S33
           ! mov c,eax
           ! mov ebx,d
           ! add eax,ebx
           ! mov c,eax
           ! mov eax,c
           ! mov edx,d
           ! xor eax,edx
           ! xor eax,a
           ! add eax,b
           ! add eax,&H4881d05
           ! mov ebx,bBuf
           ! add ebx,24
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov b,eax
           ! rol eax,%S34
           ! mov b,eax
           ! mov ebx,c
           ! add eax,ebx
           ! mov b,eax
           ! mov eax,b
           ! mov edx,c
           ! xor eax,edx
           ! xor eax,d
           ! add eax,a
           ! add eax,&Hd9d4d039
           ! mov ebx,bBuf
           ! add ebx,36
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov a,eax
           ! rol eax,%S31
           ! mov a,eax
           ! mov ebx,b
           ! add eax,ebx
           ! mov a,eax
           ! mov eax,a
           ! mov edx,b
           ! xor eax,edx
           ! xor eax,c
           ! add eax,d
           ! add eax,&He6db99e5
           ! mov ebx,bBuf
           ! add ebx,48
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov d,eax
           ! rol eax,%S32
           ! mov d,eax
           ! mov ebx,a
           ! add eax,ebx
           ! mov d,eax
           ! mov eax,d
           ! mov edx,a
           ! xor eax,edx
           ! xor eax,b
           ! add eax,c
           ! add eax,&H1fa27cf8
           ! mov ebx,bBuf
           ! add ebx,60
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov c,eax
           ! rol eax,%S33
           ! mov c,eax
           ! mov ebx,d
           ! add eax,ebx
           ! mov c,eax
           ! mov eax,c
           ! mov edx,d
           ! xor eax,edx
           ! xor eax,a
           ! add eax,b
           ! add eax,&Hc4ac5665
           ! mov ebx,bBuf
           ! add ebx,8
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov b,eax
           ! rol eax,%S34
           ! mov b,eax
           ! mov ebx,c
           ! add eax,ebx
           ! mov b,eax
           ! mov edx,d
           ! not edx
           ! mov ebx,b
           ! or edx,ebx
           ! mov eax,c
           ! xor eax,edx
           ! add eax,a
           ! add eax,&Hf4292244
           ! mov ebx,bBuf
           ! add ebx,0
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov a,eax
           ! rol eax,%S41
           ! mov a,eax
           ! mov ebx,b
           ! add eax,ebx
           ! mov a,eax
           ! mov edx,c
           ! not edx
           ! mov ebx,a
           ! or edx,ebx
           ! mov eax,b
           ! xor eax,edx
           ! add eax,d
           ! add eax,&H432aff97
           ! mov ebx,bBuf
           ! add ebx,28
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov d,eax
           ! rol eax,%S42
           ! mov d,eax
           ! mov ebx,a
           ! add eax,ebx
           ! mov d,eax
           ! mov edx,b
           ! not edx
           ! mov ebx,d
           ! or edx,ebx
           ! mov eax,a
           ! xor eax,edx
           ! add eax,c
           ! add eax,&Hab9423a7
           ! mov ebx,bBuf
           ! add ebx,56
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov c,eax
           ! rol eax,%S43
           ! mov c,eax
           ! mov ebx,d
           ! add eax,ebx
           ! mov c,eax
           ! mov edx,a
           ! not edx
           ! mov ebx,c
           ! or edx,ebx
           ! mov eax,d
           ! xor eax,edx
           ! add eax,b
           ! add eax,&Hfc93a039
           ! mov ebx,bBuf
           ! add ebx,20
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov b,eax
           ! rol eax,%S44
           ! mov b,eax
           ! mov ebx,c
           ! add eax,ebx
           ! mov b,eax
           ! mov edx,d
           ! not edx
           ! mov ebx,b
           ! or edx,ebx
           ! mov eax,c
           ! xor eax,edx
           ! add eax,a
           ! add eax,&H655b59c3
           ! mov ebx,bBuf
           ! add ebx,48
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov a,eax
           ! rol eax,%S41
           ! mov a,eax
           ! mov ebx,b
           ! add eax,ebx
           ! mov a,eax
           ! mov edx,c
           ! not edx
           ! mov ebx,a
           ! or edx,ebx
           ! mov eax,b
           ! xor eax,edx
           ! add eax,d
           ! add eax,&H8f0ccc92
           ! mov ebx,bBuf
           ! add ebx,12
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov d,eax
           ! rol eax,%S42
           ! mov d,eax
           ! mov ebx,a
           ! add eax,ebx
           ! mov d,eax
           ! mov edx,b
           ! not edx
           ! mov ebx,d
           ! or edx,ebx
           ! mov eax,a
           ! xor eax,edx
           ! add eax,c
           ! add eax,&Hffeff47d
           ! mov ebx,bBuf
           ! add ebx,40
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov c,eax
           ! rol eax,%S43
           ! mov c,eax
           ! mov ebx,d
           ! add eax,ebx
           ! mov c,eax
           ! mov edx,a
           ! not edx
           ! mov ebx,c
           ! or edx,ebx
           ! mov eax,d
           ! xor eax,edx
           ! add eax,b
           ! add eax,&H85845dd1
           ! mov ebx,bBuf
           ! add ebx,4
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov b,eax
           ! rol eax,%S44
           ! mov b,eax
           ! mov ebx,c
           ! add eax,ebx
           ! mov b,eax
           ! mov edx,d
           ! not edx
           ! mov ebx,b
           ! or edx,ebx
           ! mov eax,c
           ! xor eax,edx
           ! add eax,a
           ! add eax,&H6fa87e4f
           ! mov ebx,bBuf
           ! add ebx,32
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov a,eax
           ! rol eax,%S41
           ! mov a,eax
           ! mov ebx,b
           ! add eax,ebx
           ! mov a,eax
           ! mov edx,c
           ! not edx
           ! mov ebx,a
           ! or edx,ebx
           ! mov eax,b
           ! xor eax,edx
           ! add eax,d
           ! add eax,&Hfe2ce6e0
           ! mov ebx,bBuf
           ! add ebx,60
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov d,eax
           ! rol eax,%S42
           ! mov d,eax
           ! mov ebx,a
           ! add eax,ebx
           ! mov d,eax
           ! mov edx,b
           ! not edx
           ! mov ebx,d
           ! or edx,ebx
           ! mov eax,a
           ! xor eax,edx
           ! add eax,c
           ! add eax,&Ha3014314
           ! mov ebx,bBuf
           ! add ebx,24
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov c,eax
           ! rol eax,%S43
           ! mov c,eax
           ! mov ebx,d
           ! add eax,ebx
           ! mov c,eax
           ! mov edx,a
           ! not edx
           ! mov ebx,c
           ! or edx,ebx
           ! mov eax,d
           ! xor eax,edx
           ! add eax,b
           ! add eax,&H4e0811a1
           ! mov ebx,bBuf
           ! add ebx,52
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov b,eax
           ! rol eax,%S44
           ! mov b,eax
           ! mov ebx,c
           ! add eax,ebx
           ! mov b,eax
           ! mov edx,d
           ! not edx
           ! mov ebx,b
           ! or edx,ebx
           ! mov eax,c
           ! xor eax,edx
           ! add eax,a
           ! add eax,&Hf7537e82
           ! mov ebx,bBuf
           ! add ebx,16
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov a,eax
           ! rol eax,%S41
           ! mov a,eax
           ! mov ebx,b
           ! add eax,ebx
           ! mov a,eax
           ! mov edx,c
           ! not edx
           ! mov ebx,a
           ! or edx,ebx
           ! mov eax,b
           ! xor eax,edx
           ! add eax,d
           ! add eax,&Hbd3af235
           ! mov ebx,bBuf
           ! add ebx,44
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov d,eax
           ! rol eax,%S42
           ! mov d,eax
           ! mov ebx,a
           ! add eax,ebx
           ! mov d,eax
           ! mov edx,b
           ! not edx
           ! mov ebx,d
           ! or edx,ebx
           ! mov eax,a
           ! xor eax,edx
           ! add eax,c
           ! add eax,&H2ad7d2bb
           ! mov ebx,bBuf
           ! add ebx,8
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov c,eax
           ! rol eax,%S43
           ! mov c,eax
           ! mov ebx,d
           ! add eax,ebx
           ! mov c,eax
           ! mov edx,a
           ! not edx
           ! mov ebx,c
           ! or edx,ebx
           ! mov eax,d
           ! xor eax,edx
           ! add eax,b
           ! add eax,&Heb86d391
           ! mov ebx,bBuf
           ! add ebx,36
           ! mov ebx,[ebx]
           ! add eax,ebx
           ! mov b,eax
           ! rol eax,%S44
           ! mov b,eax
           ! mov ebx,c
           ! add eax,ebx
           ! mov b,eax
           ctx.lState( 0 ) = ctx.lState( 0 ) + a
           ctx.lState( 1 ) = ctx.lState( 1 ) + b
           ctx.lState( 2 ) = ctx.lState( 2 ) + c
           ctx.lState( 3 ) = ctx.lState( 3 ) + d
      END SUB

      Comment


      • #4
        #INCLUDE "WIN32API.INC"
        ' Constants FOR md5_Transform routine.
        %S11 = 7
        %S12 = 12
        %S13 = 17
        %S14 = 22
        %S21 = 5
        %S22 = 9
        %S23 = 14
        %S24 = 20
        %S31 = 4
        %S32 = 11
        %S33 = 16
        %S34 = 23
        %S41 = 6
        %S42 = 10
        %S43 = 15
        %S44 = 21

        TYPE t_MD5_CTX
        lState( 4 ) AS DWORD 'state (ABCD)
        lCount( 1 ) AS DWORD 'number of bits modulo 2^64 (lsp first)
        bBuf AS ASCIIZ * 64 'input buffer
        END TYPE


        SUB md5_init( BYREF ctx AS t_MD5_CTX )
        'MD5 initialization. Begins an MD5 operation, writing a new context
        ctx.lCount( 0 ) = 0
        ctx.lCount( 1 ) = 0
        ' Load magic initialization constants.
        ctx.lState( 0 ) = &H67452301
        ctx.lState( 1 ) = &HEFCDAB89
        ctx.lState( 2 ) = &H98BADCFE
        ctx.lState( 3 ) = &H10325476
        END SUB

        ' Update context TO reflect the concatenation of another buffer full
        ' of bytes.
        SUB md5_Update( BYREF ctx AS t_MD5_CTX, BYVAL bBuf AS BYTE PTR, BYVAL dwLen AS DWORD )
        LOCAL t AS DWORD
        LOCAL tmp AS DWORD

        ' Update bitcount
        t = ctx.lCount( 0 )
        tmp = dwlen
        ! shl tmp , 3
        ctx.lCount( 0 ) = t + tmp '+ md5_shiftLeft(dwLen,3)


        IF ctx.lCount( 0 ) < t THEN
        INCR ctx.lCount( 1 ) 'carry from low to high
        END IF

        tmp = dwlen
        ! shr tmp , 29
        ctx.lCount( 1 ) = ctx.lCount( 1 ) + tmp
        ! shr t , 3
        ! and t ,&H3F

        'handle any leading odd-sized chunks
        IF ISTRUE( t ) THEN
        LOCAL p AS BYTE PTR

        p = VARPTR( ctx.bBuf )
        p = p + t
        t = 64 - t
        IF dwLen < t THEN
        CALL MoveMemory( BYVAL p, BYVAL bBuf, dwLen )
        EXIT SUB
        END IF
        CALL MoveMemory( BYVAL p, BYVAL bBuf, t )
        CALL md5_Transform( ctx, VARPTR( ctx.bBuf ))
        bBuf = bBuf + t
        dwLen = dwLen - t
        END IF
        'Process DATA IN 64-BYTE chunks
        DO WHILE( dwLen > = 64 )
        CALL MoveMemory( BYVAL VARPTR( ctx.bBuf ), BYVAL bBuf, 64 )
        CALL md5_Transform( ctx, VARPTR( ctx.bBuf ))
        bBuf = bBuf + 64
        dwLen = dwLen - 64
        LOOP
        'handle any remaining bytes of data
        CALL MoveMemory( BYVAL VARPTR( ctx.bBuf ), BYVAL bBuf, dwLen )
        END SUB

        ' Final wrapup - pad TO 64-BYTE boundary WITH the BIT pattern
        ' 1 0* (64-BIT count of bits processed, MSB-first)
        SUB md5_Final( BYVAL bDigest AS BYTE PTR, ctx AS t_MD5_CTX )
        LOCAL lCount AS DWORD
        LOCAL tmp AS DWORD
        LOCAL tmp1 AS DWORD
        LOCAL x AS DWORD
        LOCAL p AS BYTE PTR
        LOCAL bBuffer AS BYTE PTR

        bBuffer = VARPTR( ctx.bBuf )
        'Compute number of bytes MOD 64
        tmp = ctx.lCount( 0 )
        ! shr tmp , 3
        ! and tmp , &H3F

        'lCount=(md5_shiftRight(ctx.lCount(0),3) AND &H3F)
        lCount = tmp

        'set the first char of padding to &H80. This is safe since there is
        'always AT least one BYTE free
        p = VARPTR( ctx.bBuf )
        p = p + lCount
        @p = &H80
        INCR p
        ' Bytes of padding needed TO make 64 bytes
        lCount = 64 - 1 - lCount
        ' Pad out TO 56 MOD 64
        IF lCount < 8 THEN
        'two lots of padding: pad the first block to 64 bytes
        ' CALL FillMemory(p,lCount,0)
        tmp = p
        FOR x = 1 TO lCount
        POKE BYTE, tmp, 0
        INCR tmp
        NEXT x

        CALL md5_Transform( ctx, VARPTR( ctx.bBuf ))


        tmp = VARPTR( ctx.bBuf )
        FOR x = 1 TO 56
        POKE BYTE, tmp, 0
        INCR tmp
        NEXT x
        ELSE
        'pad block to 56 bytes

        tmp = p
        FOR x = 1 TO lCount - 8
        POKE BYTE, tmp, 0
        INCR tmp
        NEXT x
        END IF
        'append length IN bits and transform

        CALL MoveMemory( BYVAL VARPTR( @bBuffer[56] ), BYVAL VARPTR( ctx.lCount( 0 )), 4 )
        CALL MoveMemory( BYVAL VARPTR( @bBuffer[60] ), BYVAL VARPTR( ctx.lCount( 1 )), 4 )
        CALL md5_Transform( ctx, VARPTR( ctx.bBuf ))
        CALL MoveMemory( BYVAL bDigest, BYVAL VARPTR( ctx.lState( 0 )), 16 )

        END SUB
        FUNCTION md5_Digest( BYREF ctx AS t_MD5_CTX ) AS STRING
        'returns the MD5 digest as a hex string
        DIM sHex AS STRING
        DIM szDigest AS ASCIIZ * 16
        DIM bDigest AS BYTE PTR
        DIM sCheck AS STRING
        DIM i AS DWORD

        bDigest = VARPTR( szDigest )
        CALL md5_Final( bDigest, ctx )
        IF bDigest < > %NULL THEN
        FOR i = 0 TO 15
        sHex = sHex + HEX$( @bDigest[i], 2 )
        NEXT
        END IF

        FUNCTION = sHex
        END FUNCTION
        SUB md5_readFile( BYREF ctx AS t_MD5_CTX, szFile AS ASCIIZ )

        'reads a file and calls md5_Update on the buffer
        'md5_Init() MUST have been called prior to calling
        'this function - call md5_Digest() afterwards to
        'get the fingerprint
        LOCAL hFile AS DWORD
        LOCAL szBuffer AS ASCIIZ * 65536
        LOCAL lBufLen AS DWORD
        LOCAL lLen AS DWORD
        LOCAL lResult AS DWORD
        LOCAL lToRead AS DWORD
        LOCAL lToReadHigh AS DWORD
        LOCAL lpBuffer AS DWORD

        lBufLen = SIZEOF( szBuffer )
        lpBuffer = VARPTR( szBuffer )
        hFile = CreateFile( szFile, %GENERIC_READ, %FILE_SHARE_READ, _
        BYVAL %NULL, %OPEN_EXISTING, %FILE_ATTRIBUTE_NORMAL, 0& )
        IF hFile < > %INVALID_HANDLE_VALUE THEN
        lToRead = GetFileSize( hFile, lToReadHigh )
        md5_readFile_loop:
        lResult = ReadFile( hFile, BYVAL lpBuffer, lBufLen, lLen, BYVAL %NULL )
        IF lResult = 0 THEN GOTO md5_readFile_close
        CALL md5_Update( ctx, lpBuffer, lLen )
        lToRead = lToRead - lLen
        IF lToRead = 0 THEN GOTO md5_readFile_close
        GOTO md5_readFile_loop
        md5_readFile_close:
        CALL CloseHandle( hFile )
        END IF
        END SUB
        SUB test()

        'implements the Md5 test suite to make sure that the
        'implementation is correct
        DIM ctx AS t_MD5_CTX
        DIM szText AS ASCIIZ * 256

        CALL md5_Init( ctx ) 'call md5_Init each time to calculate a new digest
        szText = ""
        CALL md5_Update( ctx, VARPTR( szText ), LEN( szText ))
        ?( "Got: " + LCASE$( md5_Digest( ctx )))
        ?( "Expected: d41d8cd98f00b204e9800998ecf8427e" )
        CALL md5_Init( ctx ) 'call md5_Init each time to calculate a new digest
        szText = "a"
        CALL md5_Update( ctx, VARPTR( szText ), LEN( szText ))
        ?( "Got: " + LCASE$( md5_Digest( ctx )))
        ?( "Expected: 0cc175b9c0f1b6a831c399e269772661" )
        CALL md5_Init( ctx ) 'call md5_Init each time to calculate a new digest
        szText = "abc"
        CALL md5_Update( ctx, VARPTR( szText ), LEN( szText ))
        ?( "Got: " + LCASE$( md5_Digest( ctx )))
        ?( "Expected: 900150983cd24fb0d6963f7d28e17f72" )
        CALL md5_Init( ctx ) 'call md5_Init each time to calculate a new digest
        szText = "message digest"
        CALL md5_Update( ctx, VARPTR( szText ), LEN( szText ))
        ?( "Got: " + LCASE$( md5_Digest( ctx )))
        ?( "Expected: f96b697d7cb7938d525a2f31aaf161d0" )
        CALL md5_Init( ctx ) 'call md5_Init each time to calculate a new digest
        szText = "abcdefghijklmnopqrstuvwxyz"
        CALL md5_Update( ctx, VARPTR( szText ), LEN( szText ))
        ?( "Got: " + LCASE$( md5_Digest( ctx )))
        ?( "Expected: c3fcd3d76192e4007dfb496cca67e13b" )
        CALL md5_Init( ctx ) 'call md5_Init each time to calculate a new digest
        szText = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
        CALL md5_Update( ctx, VARPTR( szText ), LEN( szText ))
        ?( "Got: " + LCASE$( md5_Digest( ctx )))
        ?( "Expected: d174ab98d277d9f5a5611c2c9f419d9f" )
        CALL md5_Init( ctx ) 'call md5_Init each time to calculate a new digest
        szText = "12345678901234567890123456789012345678901234567890123456789012345678901234567890"
        CALL md5_Update( ctx, VARPTR( szText ), LEN( szText ))
        ?( "Got: " + LCASE$( md5_Digest( ctx )))
        ?( "Expected: 57edf4a22be3c955ac49da2e2107b67a" )

        END SUB
        FUNCTION PBMAIN() AS LONG
        CALL Test()
        CALL testfile()

        ? "Done press any key."
        WAITKEY$

        END FUNCTION
        SUB testfile()
        LOCAL szText AS ASCIIZ*256
        LOCAL ctx AS t_MD5_CTX

        CALL md5_Init(ctx) 'call md5_Init each time to calculate a new digest

        CALL md5_readFile(ctx,"C:\temp\u.iso") '-----------------your test file

        CALL md5_Update(ctx,VARPTR(szText),LEN(szText))

        ?("MD5= "+LCASE$(md5_Digest(ctx)))

        END SUB

        SUB md5_Transform( BYREF ctx AS t_MD5_CTX, BYVAL bBuf AS DWORD PTR )
        #DEBUG CODE OFF
        LOCAL a AS DWORD
        LOCAL b AS DWORD
        LOCAL c AS DWORD
        LOCAL d AS DWORD

        a = ctx.lState( 0 )
        b = ctx.lState( 1 )
        c = ctx.lState( 2 )
        d = ctx.lState( 3 )


        #ALIGN 4

        ! mov ecx,b
        ! mov edx,c
        ! and edx,ecx
        ! not ecx
        ! mov eax,d
        ! and ecx,eax
        ! or ecx,edx
        ! mov eax,a
        ! add eax,ecx
        ! add eax,&Hd76aa478
        ! mov ebx,bBuf
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov a,eax
        ! rol eax,%S11
        ! mov a,eax
        ! mov ebx,b
        ! add eax,ebx
        ! mov a,eax
        ! mov ecx,a
        ! mov edx,b
        ! and edx,ecx
        ! not ecx
        ! mov eax,c
        ! and ecx,eax
        ! or ecx,edx
        ! mov eax,d
        ! add eax,ecx
        ! add eax,&He8c7b756
        ! mov ebx,bBuf
        ! add ebx,4
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov d,eax
        ! rol eax,%S12
        ! mov d,eax
        ! mov ebx,a
        ! add eax,ebx
        ! mov d,eax
        ! mov ecx,d
        ! mov edx,a
        ! and edx,ecx
        ! not ecx
        ! mov eax,b
        ! and ecx,eax
        ! or ecx,edx
        ! mov eax,c
        ! add eax,ecx
        ! add eax,&H242070db
        ! mov ebx,bBuf
        ! add ebx,8
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov c,eax
        ! rol eax,%S13
        ! mov c,eax
        ! mov ebx,d
        ! add eax,ebx
        ! mov c,eax
        ! mov ecx,c
        ! mov edx,d
        ! and edx,ecx
        ! not ecx
        ! mov eax,a
        ! and ecx,eax
        ! or ecx,edx
        ! mov eax,b
        ! add eax,ecx
        ! add eax,&Hc1bdceee
        ! mov ebx,bBuf
        ! add ebx,12
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov b,eax
        ! rol eax,%S14
        ! mov b,eax
        ! mov ebx,c
        ! add eax,ebx
        ! mov b,eax
        ! mov ecx,b
        ! mov edx,c
        ! and edx,ecx
        ! not ecx
        ! mov eax,d
        ! and ecx,eax
        ! or ecx,edx
        ! mov eax,a
        ! add eax,ecx
        ! add eax,&Hf57c0faf
        ! mov ebx,bBuf
        ! add ebx,16
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov a,eax
        ! rol eax,%S11
        ! mov a,eax
        ! mov ebx,b
        ! add eax,ebx
        ! mov a,eax
        ! mov ecx,a
        ! mov edx,b
        ! and edx,ecx
        ! not ecx
        ! mov eax,c
        ! and ecx,eax
        ! or ecx,edx
        ! mov eax,d
        ! add eax,ecx
        ! add eax,&H4787c62a
        ! mov ebx,bBuf
        ! add ebx,20
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov d,eax
        ! rol eax,%S12
        ! mov d,eax
        ! mov ebx,a
        ! add eax,ebx
        ! mov d,eax
        ! mov ecx,d
        ! mov edx,a
        ! and edx,ecx
        ! not ecx
        ! mov eax,b
        ! and ecx,eax
        ! or ecx,edx
        ! mov eax,c
        ! add eax,ecx
        ! add eax,&Ha8304613
        ! mov ebx,bBuf
        ! add ebx,24
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov c,eax
        ! rol eax,%S13
        ! mov c,eax
        ! mov ebx,d
        ! add eax,ebx
        ! mov c,eax
        ! mov ecx,c
        ! mov edx,d
        ! and edx,ecx
        ! not ecx
        ! mov eax,a
        ! and ecx,eax
        ! or ecx,edx
        ! mov eax,b
        ! add eax,ecx
        ! add eax,&Hfd469501
        ! mov ebx,bBuf
        ! add ebx,28
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov b,eax
        ! rol eax,%S14
        ! mov b,eax
        ! mov ebx,c
        ! add eax,ebx
        ! mov b,eax
        ! mov ecx,b
        ! mov edx,c
        ! and edx,ecx
        ! not ecx
        ! mov eax,d
        ! and ecx,eax
        ! or ecx,edx
        ! mov eax,a
        ! add eax,ecx
        ! add eax,&H698098d8
        ! mov ebx,bBuf
        ! add ebx,32
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov a,eax
        ! rol eax,%S11
        ! mov a,eax
        ! mov ebx,b
        ! add eax,ebx
        ! mov a,eax
        ! mov ecx,a
        ! mov edx,b
        ! and edx,ecx
        ! not ecx
        ! mov eax,c
        ! and ecx,eax
        ! or ecx,edx
        ! mov eax,d
        ! add eax,ecx
        ! add eax,&H8b44f7af
        ! mov ebx,bBuf
        ! add ebx,36
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov d,eax
        ! rol eax,%S12
        ! mov d,eax
        ! mov ebx,a
        ! add eax,ebx
        ! mov d,eax
        ! mov ecx,d
        ! mov edx,a
        ! and edx,ecx
        ! not ecx
        ! mov eax,b
        ! and ecx,eax
        ! or ecx,edx
        ! mov eax,c
        ! add eax,ecx
        ! add eax,&Hffff5bb1
        ! mov ebx,bBuf
        ! add ebx,40
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov c,eax
        ! rol eax,%S13
        ! mov c,eax
        ! mov ebx,d
        ! add eax,ebx
        ! mov c,eax
        ! mov ecx,c
        ! mov edx,d
        ! and edx,ecx
        ! not ecx
        ! mov eax,a
        ! and ecx,eax
        ! or ecx,edx
        ! mov eax,b
        ! add eax,ecx
        ! add eax,&H895cd7be
        ! mov ebx,bBuf
        ! add ebx,44
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov b,eax
        ! rol eax,%S14
        ! mov b,eax
        ! mov ebx,c
        ! add eax,ebx
        ! mov b,eax
        ! mov ecx,b
        ! mov edx,c
        ! and edx,ecx
        ! not ecx
        ! mov eax,d
        ! and ecx,eax
        ! or ecx,edx
        ! mov eax,a
        ! add eax,ecx
        ! add eax,&H6b901122
        ! mov ebx,bBuf
        ! add ebx,48
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov a,eax
        ! rol eax,%S11
        ! mov a,eax
        ! mov ebx,b
        ! add eax,ebx
        ! mov a,eax
        ! mov ecx,a
        ! mov edx,b
        ! and edx,ecx
        ! not ecx
        ! mov eax,c
        ! and ecx,eax
        ! or ecx,edx
        ! mov eax,d
        ! add eax,ecx
        ! add eax,&Hfd987193
        ! mov ebx,bBuf
        ! add ebx,52
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov d,eax
        ! rol eax,%S12
        ! mov d,eax
        ! mov ebx,a
        ! add eax,ebx
        ! mov d,eax
        ! mov ecx,d
        ! mov edx,a
        ! and edx,ecx
        ! not ecx
        ! mov eax,b
        ! and ecx,eax
        ! or ecx,edx
        ! mov eax,c
        ! add eax,ecx
        ! add eax,&Ha679438e
        ! mov ebx,bBuf
        ! add ebx,56
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov c,eax
        ! rol eax,%S13
        ! mov c,eax
        ! mov ebx,d
        ! add eax,ebx
        ! mov c,eax
        ! mov ecx,c
        ! mov edx,d
        ! and edx,ecx
        ! not ecx
        ! mov eax,a
        ! and ecx,eax
        ! or ecx,edx
        ! mov eax,b
        ! add eax,ecx
        ! add eax,&H49b40821
        ! mov ebx,bBuf
        ! add ebx,60
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov b,eax
        ! rol eax,%S14
        ! mov b,eax
        ! mov ebx,c
        ! add eax,ebx
        ! mov b,eax
        ! mov ecx,d
        ! mov edx,b
        ! and edx,ecx
        ! not ecx
        ! mov eax,c
        ! and ecx,eax
        ! or ecx,edx
        ! mov eax,a
        ! add eax,ecx
        ! add eax,&Hf61e2562
        ! mov ebx,bBuf
        ! add ebx,4
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov a,eax
        ! rol eax,%S21
        ! mov a,eax
        ! mov ebx,b
        ! add eax,ebx
        ! mov a,eax
        ! mov ecx,c
        ! mov edx,a
        ! and edx,ecx
        ! not ecx
        ! mov eax,b
        ! and ecx,eax
        ! or ecx,edx
        ! mov eax,d
        ! add eax,ecx
        ! add eax,&Hc040b340
        ! mov ebx,bBuf
        ! add ebx,24
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov d,eax
        ! rol eax,%S22
        ! mov d,eax
        ! mov ebx,a
        ! add eax,ebx
        ! mov d,eax
        ! mov ecx,b
        ! mov edx,d
        ! and edx,ecx
        ! not ecx
        ! mov eax,a
        ! and ecx,eax
        ! or ecx,edx
        ! mov eax,c
        ! add eax,ecx
        ! add eax,&H265e5a51
        ! mov ebx,bBuf
        ! add ebx,44
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov c,eax
        ! rol eax,%S23
        ! mov c,eax
        ! mov ebx,d
        ! add eax,ebx
        ! mov c,eax
        ! mov ecx,a
        ! mov edx,c
        ! and edx,ecx
        ! not ecx
        ! mov eax,d
        ! and ecx,eax
        ! or ecx,edx
        ! mov eax,b
        ! add eax,ecx
        ! add eax,&He9b6c7aa
        ! mov ebx,bBuf
        ! add ebx,0
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov b,eax
        ! rol eax,%S24
        ! mov b,eax
        ! mov ebx,c
        ! add eax,ebx
        ! mov b,eax
        ! mov ecx,d
        ! mov edx,b
        ! and edx,ecx
        ! not ecx
        ! mov eax,c
        ! and ecx,eax
        ! or ecx,edx
        ! mov eax,a
        ! add eax,ecx
        ! add eax,&Hd62f105d
        ! mov ebx,bBuf
        ! add ebx,20
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov a,eax
        ! rol eax,%S21
        ! mov a,eax
        ! mov ebx,b
        ! add eax,ebx
        ! mov a,eax
        ! mov ecx,c
        ! mov edx,a
        ! and edx,ecx
        ! not ecx
        ! mov eax,b
        ! and ecx,eax
        ! or ecx,edx
        ! mov eax,d
        ! add eax,ecx
        ! add eax,&H2441453
        ! mov ebx,bBuf
        ! add ebx,40
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov d,eax
        ! rol eax,%S22
        ! mov d,eax
        ! mov ebx,a
        ! add eax,ebx
        ! mov d,eax
        ! mov ecx,b
        ! mov edx,d
        ! and edx,ecx
        ! not ecx
        ! mov eax,a
        ! and ecx,eax
        ! or ecx,edx
        ! mov eax,c
        ! add eax,ecx
        ! add eax,&Hd8a1e681
        ! mov ebx,bBuf
        ! add ebx,60
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov c,eax
        ! rol eax,%S23
        ! mov c,eax
        ! mov ebx,d
        ! add eax,ebx
        ! mov c,eax
        ! mov ecx,a
        ! mov edx,c
        ! and edx,ecx
        ! not ecx
        ! mov eax,d
        ! and ecx,eax
        ! or ecx,edx
        ! mov eax,b
        ! add eax,ecx
        ! add eax,&He7d3fbc8
        ! mov ebx,bBuf
        ! add ebx,16
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov b,eax
        ! rol eax,%S24
        ! mov b,eax
        ! mov ebx,c
        ! add eax,ebx
        ! mov b,eax
        ! mov ecx,d
        ! mov edx,b
        ! and edx,ecx
        ! not ecx
        ! mov eax,c
        ! and ecx,eax
        ! or ecx,edx
        ! mov eax,a
        ! add eax,ecx
        ! add eax,&H21e1cde6
        ! mov ebx,bBuf
        ! add ebx,36
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov a,eax
        ! rol eax,%S21
        ! mov a,eax
        ! mov ebx,b
        ! add eax,ebx
        ! mov a,eax
        ! mov ecx,c
        ! mov edx,a
        ! and edx,ecx
        ! not ecx
        ! mov eax,b
        ! and ecx,eax
        ! or ecx,edx
        ! mov eax,d
        ! add eax,ecx
        ! add eax,&Hc33707d6
        ! mov ebx,bBuf
        ! add ebx,56
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov d,eax
        ! rol eax,%S22
        ! mov d,eax
        ! mov ebx,a
        ! add eax,ebx
        ! mov d,eax
        ! mov ecx,b
        ! mov edx,d
        ! and edx,ecx
        ! not ecx
        ! mov eax,a
        ! and ecx,eax
        ! or ecx,edx
        ! mov eax,c
        ! add eax,ecx
        ! add eax,&Hf4d50d87
        ! mov ebx,bBuf
        ! add ebx,12
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov c,eax
        ! rol eax,%S23
        ! mov c,eax
        ! mov ebx,d
        ! add eax,ebx
        ! mov c,eax
        ! mov ecx,a
        ! mov edx,c
        ! and edx,ecx
        ! not ecx
        ! mov eax,d
        ! and ecx,eax
        ! or ecx,edx
        ! mov eax,b
        ! add eax,ecx
        ! add eax,&H455a14ed
        ! mov ebx,bBuf
        ! add ebx,32
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov b,eax
        ! rol eax,%S24
        ! mov b,eax
        ! mov ebx,c
        ! add eax,ebx
        ! mov b,eax
        ! mov ecx,d
        ! mov edx,b
        ! and edx,ecx
        ! not ecx
        ! mov eax,c
        ! and ecx,eax
        ! or ecx,edx
        ! mov eax,a
        ! add eax,ecx
        ! add eax,&Ha9e3e905
        ! mov ebx,bBuf
        ! add ebx,52
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov a,eax
        ! rol eax,%S21
        ! mov a,eax
        ! mov ebx,b
        ! add eax,ebx
        ! mov a,eax
        ! mov ecx,c
        ! mov edx,a
        ! and edx,ecx
        ! not ecx
        ! mov eax,b
        ! and ecx,eax
        ! or ecx,edx
        ! mov eax,d
        ! add eax,ecx
        ! add eax,&Hfcefa3f8
        ! mov ebx,bBuf
        ! add ebx,8
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov d,eax
        ! rol eax,%S22
        ! mov d,eax
        ! mov ebx,a
        ! add eax,ebx
        ! mov d,eax
        ! mov ecx,b
        ! mov edx,d
        ! and edx,ecx
        ! not ecx
        ! mov eax,a
        ! and ecx,eax
        ! or ecx,edx
        ! mov eax,c
        ! add eax,ecx
        ! add eax,&H676f02d9
        ! mov ebx,bBuf
        ! add ebx,28
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov c,eax
        ! rol eax,%S23
        ! mov c,eax
        ! mov ebx,d
        ! add eax,ebx
        ! mov c,eax
        ! mov ecx,a
        ! mov edx,c
        ! and edx,ecx
        ! not ecx
        ! mov eax,d
        ! and ecx,eax
        ! or ecx,edx
        ! mov eax,b
        ! add eax,ecx
        ! add eax,&H8d2a4c8a
        ! mov ebx,bBuf
        ! add ebx,48
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov b,eax
        ! rol eax,%S24
        ! mov b,eax
        ! mov ebx,c
        ! add eax,ebx
        ! mov b,eax
        ! mov eax,b
        ! mov edx,c
        ! xor eax,edx
        ! xor eax,d
        ! add eax,a
        ! add eax,&Hfffa3942
        ! mov ebx,bBuf
        ! add ebx,20
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov a,eax
        ! rol eax,%S31
        ! mov a,eax
        ! mov ebx,b
        ! add eax,ebx
        ! mov a,eax
        ! mov eax,a
        ! mov edx,b
        ! xor eax,edx
        ! xor eax,c
        ! add eax,d
        ! add eax,&H8771f681
        ! mov ebx,bBuf
        ! add ebx,32
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov d,eax
        ! rol eax,%S32
        ! mov d,eax
        ! mov ebx,a
        ! add eax,ebx
        ! mov d,eax
        ! mov eax,d
        ! mov edx,a
        ! xor eax,edx
        ! xor eax,b
        ! add eax,c
        ! add eax,&H6d9d6122
        ! mov ebx,bBuf
        ! add ebx,44
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov c,eax
        ! rol eax,%S33
        ! mov c,eax
        ! mov ebx,d
        ! add eax,ebx
        ! mov c,eax
        ! mov eax,c
        ! mov edx,d
        ! xor eax,edx
        ! xor eax,a
        ! add eax,b
        ! add eax,&Hfde5380c
        ! mov ebx,bBuf
        ! add ebx,56
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov b,eax
        ! rol eax,%S34
        ! mov b,eax
        ! mov ebx,c
        ! add eax,ebx
        ! mov b,eax
        ! mov eax,b
        ! mov edx,c
        ! xor eax,edx
        ! xor eax,d
        ! add eax,a
        ! add eax,&Ha4beea44
        ! mov ebx,bBuf
        ! add ebx,4
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov a,eax
        ! rol eax,%S31
        ! mov a,eax
        ! mov ebx,b
        ! add eax,ebx
        ! mov a,eax
        ! mov eax,a
        ! mov edx,b
        ! xor eax,edx
        ! xor eax,c
        ! add eax,d
        ! add eax,&H4bdecfa9
        ! mov ebx,bBuf
        ! add ebx,16
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov d,eax
        ! rol eax,%S32
        ! mov d,eax
        ! mov ebx,a
        ! add eax,ebx
        ! mov d,eax
        ! mov eax,d
        ! mov edx,a
        ! xor eax,edx
        ! xor eax,b
        ! add eax,c
        ! add eax,&Hf6bb4b60
        ! mov ebx,bBuf
        ! add ebx,28
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov c,eax
        ! rol eax,%S33
        ! mov c,eax
        ! mov ebx,d
        ! add eax,ebx
        ! mov c,eax
        ! mov eax,c
        ! mov edx,d
        ! xor eax,edx
        ! xor eax,a
        ! add eax,b
        ! add eax,&Hbebfbc70
        ! mov ebx,bBuf
        ! add ebx,40
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov b,eax
        ! rol eax,%S34
        ! mov b,eax
        ! mov ebx,c
        ! add eax,ebx
        ! mov b,eax
        ! mov eax,b
        ! mov edx,c
        ! xor eax,edx
        ! xor eax,d
        ! add eax,a
        ! add eax,&H289b7ec6
        ! mov ebx,bBuf
        ! add ebx,52
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov a,eax
        ! rol eax,%S31
        ! mov a,eax
        ! mov ebx,b
        ! add eax,ebx
        ! mov a,eax
        ! mov eax,a
        ! mov edx,b
        ! xor eax,edx
        ! xor eax,c
        ! add eax,d
        ! add eax,&Heaa127fa
        ! mov ebx,bBuf
        ! add ebx,0
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov d,eax
        ! rol eax,%S32
        ! mov d,eax
        ! mov ebx,a
        ! add eax,ebx
        ! mov d,eax
        ! mov eax,d
        ! mov edx,a
        ! xor eax,edx
        ! xor eax,b
        ! add eax,c
        ! add eax,&Hd4ef3085
        ! mov ebx,bBuf
        ! add ebx,12
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov c,eax
        ! rol eax,%S33
        ! mov c,eax
        ! mov ebx,d
        ! add eax,ebx
        ! mov c,eax
        ! mov eax,c
        ! mov edx,d
        ! xor eax,edx
        ! xor eax,a
        ! add eax,b
        ! add eax,&H4881d05
        ! mov ebx,bBuf
        ! add ebx,24
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov b,eax
        ! rol eax,%S34
        ! mov b,eax
        ! mov ebx,c
        ! add eax,ebx
        ! mov b,eax
        ! mov eax,b
        ! mov edx,c
        ! xor eax,edx
        ! xor eax,d
        ! add eax,a
        ! add eax,&Hd9d4d039
        ! mov ebx,bBuf
        ! add ebx,36
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov a,eax
        ! rol eax,%S31
        ! mov a,eax
        ! mov ebx,b
        ! add eax,ebx
        ! mov a,eax
        ! mov eax,a
        ! mov edx,b
        ! xor eax,edx
        ! xor eax,c
        ! add eax,d
        ! add eax,&He6db99e5
        ! mov ebx,bBuf
        ! add ebx,48
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov d,eax
        ! rol eax,%S32
        ! mov d,eax
        ! mov ebx,a
        ! add eax,ebx
        ! mov d,eax
        ! mov eax,d
        ! mov edx,a
        ! xor eax,edx
        ! xor eax,b
        ! add eax,c
        ! add eax,&H1fa27cf8
        ! mov ebx,bBuf
        ! add ebx,60
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov c,eax
        ! rol eax,%S33
        ! mov c,eax
        ! mov ebx,d
        ! add eax,ebx
        ! mov c,eax
        ! mov eax,c
        ! mov edx,d
        ! xor eax,edx
        ! xor eax,a
        ! add eax,b
        ! add eax,&Hc4ac5665
        ! mov ebx,bBuf
        ! add ebx,8
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov b,eax
        ! rol eax,%S34
        ! mov b,eax
        ! mov ebx,c
        ! add eax,ebx
        ! mov b,eax
        ! mov edx,d
        ! not edx
        ! mov ebx,b
        ! or edx,ebx
        ! mov eax,c
        ! xor eax,edx
        ! add eax,a
        ! add eax,&Hf4292244
        ! mov ebx,bBuf
        ! add ebx,0
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov a,eax
        ! rol eax,%S41
        ! mov a,eax
        ! mov ebx,b
        ! add eax,ebx
        ! mov a,eax
        ! mov edx,c
        ! not edx
        ! mov ebx,a
        ! or edx,ebx
        ! mov eax,b
        ! xor eax,edx
        ! add eax,d
        ! add eax,&H432aff97
        ! mov ebx,bBuf
        ! add ebx,28
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov d,eax
        ! rol eax,%S42
        ! mov d,eax
        ! mov ebx,a
        ! add eax,ebx
        ! mov d,eax
        ! mov edx,b
        ! not edx
        ! mov ebx,d
        ! or edx,ebx
        ! mov eax,a
        ! xor eax,edx
        ! add eax,c
        ! add eax,&Hab9423a7
        ! mov ebx,bBuf
        ! add ebx,56
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov c,eax
        ! rol eax,%S43
        ! mov c,eax
        ! mov ebx,d
        ! add eax,ebx
        ! mov c,eax
        ! mov edx,a
        ! not edx
        ! mov ebx,c
        ! or edx,ebx
        ! mov eax,d
        ! xor eax,edx
        ! add eax,b
        ! add eax,&Hfc93a039
        ! mov ebx,bBuf
        ! add ebx,20
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov b,eax
        ! rol eax,%S44
        ! mov b,eax
        ! mov ebx,c
        ! add eax,ebx
        ! mov b,eax
        ! mov edx,d
        ! not edx
        ! mov ebx,b
        ! or edx,ebx
        ! mov eax,c
        ! xor eax,edx
        ! add eax,a
        ! add eax,&H655b59c3
        ! mov ebx,bBuf
        ! add ebx,48
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov a,eax
        ! rol eax,%S41
        ! mov a,eax
        ! mov ebx,b
        ! add eax,ebx
        ! mov a,eax
        ! mov edx,c
        ! not edx
        ! mov ebx,a
        ! or edx,ebx
        ! mov eax,b
        ! xor eax,edx
        ! add eax,d
        ! add eax,&H8f0ccc92
        ! mov ebx,bBuf
        ! add ebx,12
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov d,eax
        ! rol eax,%S42
        ! mov d,eax
        ! mov ebx,a
        ! add eax,ebx
        ! mov d,eax
        ! mov edx,b
        ! not edx
        ! mov ebx,d
        ! or edx,ebx
        ! mov eax,a
        ! xor eax,edx
        ! add eax,c
        ! add eax,&Hffeff47d
        ! mov ebx,bBuf
        ! add ebx,40
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov c,eax
        ! rol eax,%S43
        ! mov c,eax
        ! mov ebx,d
        ! add eax,ebx
        ! mov c,eax
        ! mov edx,a
        ! not edx
        ! mov ebx,c
        ! or edx,ebx
        ! mov eax,d
        ! xor eax,edx
        ! add eax,b
        ! add eax,&H85845dd1
        ! mov ebx,bBuf
        ! add ebx,4
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov b,eax
        ! rol eax,%S44
        ! mov b,eax
        ! mov ebx,c
        ! add eax,ebx
        ! mov b,eax
        ! mov edx,d
        ! not edx
        ! mov ebx,b
        ! or edx,ebx
        ! mov eax,c
        ! xor eax,edx
        ! add eax,a
        ! add eax,&H6fa87e4f
        ! mov ebx,bBuf
        ! add ebx,32
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov a,eax
        ! rol eax,%S41
        ! mov a,eax
        ! mov ebx,b
        ! add eax,ebx
        ! mov a,eax
        ! mov edx,c
        ! not edx
        ! mov ebx,a
        ! or edx,ebx
        ! mov eax,b
        ! xor eax,edx
        ! add eax,d
        ! add eax,&Hfe2ce6e0
        ! mov ebx,bBuf
        ! add ebx,60
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov d,eax
        ! rol eax,%S42
        ! mov d,eax
        ! mov ebx,a
        ! add eax,ebx
        ! mov d,eax
        ! mov edx,b
        ! not edx
        ! mov ebx,d
        ! or edx,ebx
        ! mov eax,a
        ! xor eax,edx
        ! add eax,c
        ! add eax,&Ha3014314
        ! mov ebx,bBuf
        ! add ebx,24
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov c,eax
        ! rol eax,%S43
        ! mov c,eax
        ! mov ebx,d
        ! add eax,ebx
        ! mov c,eax
        ! mov edx,a
        ! not edx
        ! mov ebx,c
        ! or edx,ebx
        ! mov eax,d
        ! xor eax,edx
        ! add eax,b
        ! add eax,&H4e0811a1
        ! mov ebx,bBuf
        ! add ebx,52
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov b,eax
        ! rol eax,%S44
        ! mov b,eax
        ! mov ebx,c
        ! add eax,ebx
        ! mov b,eax
        ! mov edx,d
        ! not edx
        ! mov ebx,b
        ! or edx,ebx
        ! mov eax,c
        ! xor eax,edx
        ! add eax,a
        ! add eax,&Hf7537e82
        ! mov ebx,bBuf
        ! add ebx,16
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov a,eax
        ! rol eax,%S41
        ! mov a,eax
        ! mov ebx,b
        ! add eax,ebx
        ! mov a,eax
        ! mov edx,c
        ! not edx
        ! mov ebx,a
        ! or edx,ebx
        ! mov eax,b
        ! xor eax,edx
        ! add eax,d
        ! add eax,&Hbd3af235
        ! mov ebx,bBuf
        ! add ebx,44
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov d,eax
        ! rol eax,%S42
        ! mov d,eax
        ! mov ebx,a
        ! add eax,ebx
        ! mov d,eax
        ! mov edx,b
        ! not edx
        ! mov ebx,d
        ! or edx,ebx
        ! mov eax,a
        ! xor eax,edx
        ! add eax,c
        ! add eax,&H2ad7d2bb
        ! mov ebx,bBuf
        ! add ebx,8
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov c,eax
        ! rol eax,%S43
        ! mov c,eax
        ! mov ebx,d
        ! add eax,ebx
        ! mov c,eax
        ! mov edx,a
        ! not edx
        ! mov ebx,c
        ! or edx,ebx
        ! mov eax,d
        ! xor eax,edx
        ! add eax,b
        ! add eax,&Heb86d391
        ! mov ebx,bBuf
        ! add ebx,36
        ! mov ebx,[ebx]
        ! add eax,ebx
        ! mov b,eax
        ! rol eax,%S44
        ! mov b,eax
        ! mov ebx,c
        ! add eax,ebx
        ! mov b,eax
        ctx.lState( 0 ) = ctx.lState( 0 ) + a
        ctx.lState( 1 ) = ctx.lState( 1 ) + b
        ctx.lState( 2 ) = ctx.lState( 2 ) + c
        ctx.lState( 3 ) = ctx.lState( 3 ) + d
        END SUB

        Comment


        • #5
          Code:
          
          #INCLUDE "WIN32API.INC"
          ' Constants FOR md5_Transform routine.
             %S11 = 7
             %S12 = 12
             %S13 = 17
             %S14 = 22
             %S21 = 5
             %S22 = 9
             %S23 = 14
             %S24 = 20
             %S31 = 4
             %S32 = 11
             %S33 = 16
             %S34 = 23
             %S41 = 6
             %S42 = 10
             %S43 = 15
             %S44 = 21
          
             TYPE t_MD5_CTX
                  lState( 4 ) AS DWORD 'state (ABCD)
                  lCount( 1 ) AS DWORD 'number of bits modulo 2^64 (lsp first)
                  bBuf AS ASCIIZ * 64 'input buffer
             END TYPE
          
          
          SUB md5_init( BYREF ctx AS t_MD5_CTX )
          'MD5 initialization. Begins an MD5 operation, writing a new context
               ctx.lCount( 0 ) = 0
               ctx.lCount( 1 ) = 0
              ' Load magic initialization constants.
               ctx.lState( 0 ) = &H67452301
               ctx.lState( 1 ) = &HEFCDAB89
               ctx.lState( 2 ) = &H98BADCFE
               ctx.lState( 3 ) = &H10325476
          END SUB
          
          ' Update context TO reflect the concatenation of another buffer full
          ' of bytes.
          SUB md5_Update( BYREF ctx AS t_MD5_CTX, BYVAL bBuf AS BYTE PTR, BYVAL dwLen AS DWORD )
               LOCAL t AS DWORD
               LOCAL tmp AS DWORD
          
          ' Update bitcount
               t = ctx.lCount( 0 )
               tmp = dwlen
               ! shl tmp , 3
               ctx.lCount( 0 ) = t + tmp '+ md5_shiftLeft(dwLen,3)
          
          
               IF ctx.lCount( 0 ) < t THEN
                    INCR ctx.lCount( 1 ) 'carry from low to high
               END IF
          
               tmp = dwlen
               ! shr tmp , 29
               ctx.lCount( 1 ) = ctx.lCount( 1 ) + tmp
               ! shr t , 3
               ! and t ,&H3F
          
              'handle any leading odd-sized chunks
               IF ISTRUE( t ) THEN
                    LOCAL p AS BYTE PTR
          
                    p = VARPTR( ctx.bBuf )
                    p = p + t
                    t = 64 - t
                    IF dwLen < t THEN
                         CALL MoveMemory( BYVAL p, BYVAL bBuf, dwLen )
                         EXIT SUB
                    END IF
                    CALL MoveMemory( BYVAL p, BYVAL bBuf, t )
                    CALL md5_Transform( ctx, VARPTR( ctx.bBuf ))
                    bBuf = bBuf + t
                    dwLen = dwLen - t
               END IF
              'Process DATA IN 64-BYTE chunks
               DO WHILE( dwLen > = 64 )
                    CALL MoveMemory( BYVAL VARPTR( ctx.bBuf ), BYVAL bBuf, 64 )
                    CALL md5_Transform( ctx, VARPTR( ctx.bBuf ))
                    bBuf = bBuf + 64
                    dwLen = dwLen - 64
               LOOP
              'handle any remaining bytes of data
               CALL MoveMemory( BYVAL VARPTR( ctx.bBuf ), BYVAL bBuf, dwLen )
          END SUB
          
          ' Final wrapup - pad TO 64-BYTE boundary WITH the BIT pattern
          ' 1 0* (64-BIT count of bits processed, MSB-first)
          SUB md5_Final( BYVAL bDigest AS BYTE PTR, ctx AS t_MD5_CTX )
               LOCAL lCount AS DWORD
               LOCAL tmp AS DWORD
               LOCAL tmp1 AS DWORD
               LOCAL x AS DWORD
               LOCAL p AS BYTE PTR
               LOCAL bBuffer AS BYTE PTR
          
               bBuffer = VARPTR( ctx.bBuf )
              'Compute number of bytes MOD 64
               tmp = ctx.lCount( 0 )
                ! shr tmp , 3
                ! and tmp , &H3F
          
              'lCount=(md5_shiftRight(ctx.lCount(0),3) AND &H3F)
               lCount = tmp
          
              'set the first char of padding to &H80.  This is safe since there is
              'always AT least one BYTE free
               p = VARPTR( ctx.bBuf )
               p = p + lCount
               @p = &H80
               INCR p
              ' Bytes of padding needed TO make 64 bytes
               lCount = 64 - 1 - lCount
              ' Pad out TO 56 MOD 64
               IF lCount < 8 THEN
                  'two lots of padding: pad the first block to 64 bytes
                 ' CALL FillMemory(p,lCount,0)
                    tmp = p
                    FOR x = 1 TO lCount
                         POKE BYTE, tmp, 0
                         INCR tmp
                    NEXT x
          
                    CALL md5_Transform( ctx, VARPTR( ctx.bBuf ))
          
          
                    tmp = VARPTR( ctx.bBuf )
                    FOR x = 1 TO 56
                         POKE BYTE, tmp, 0
                         INCR tmp
                    NEXT x
               ELSE
                  'pad block to 56 bytes
          
                    tmp = p
                    FOR x = 1 TO lCount - 8
                         POKE BYTE, tmp, 0
                         INCR tmp
                    NEXT x
               END IF
              'append length IN bits and transform
          
               CALL MoveMemory( BYVAL VARPTR( @bBuffer[56] ), BYVAL VARPTR( ctx.lCount( 0 )), 4 )
               CALL MoveMemory( BYVAL VARPTR( @bBuffer[60] ), BYVAL VARPTR( ctx.lCount( 1 )), 4 )
               CALL md5_Transform( ctx, VARPTR( ctx.bBuf ))
               CALL MoveMemory( BYVAL bDigest, BYVAL VARPTR( ctx.lState( 0 )), 16 )
          
          END SUB
          FUNCTION md5_Digest( BYREF ctx AS t_MD5_CTX ) AS STRING
          'returns the MD5 digest as a hex string
               DIM sHex AS STRING
               DIM szDigest AS ASCIIZ * 16
               DIM bDigest AS BYTE PTR
               DIM sCheck AS STRING
               DIM i AS DWORD
          
               bDigest = VARPTR( szDigest )
               CALL md5_Final( bDigest, ctx )
               IF bDigest < > %NULL THEN
                    FOR i = 0 TO 15
                         sHex = sHex + HEX$( @bDigest[i], 2 )
                    NEXT
               END IF
          
               FUNCTION = sHex
          END FUNCTION
          SUB md5_readFile( BYREF ctx AS t_MD5_CTX, szFile AS ASCIIZ )
          
          'reads a file and calls md5_Update on the buffer
          'md5_Init() MUST have been called prior to calling
          'this function - call md5_Digest() afterwards to
          'get the fingerprint
               LOCAL hFile AS DWORD
               LOCAL szBuffer AS ASCIIZ * 65536
               LOCAL lBufLen AS DWORD
               LOCAL lLen AS DWORD
               LOCAL lResult AS DWORD
               LOCAL lToRead AS DWORD
               LOCAL lToReadHigh AS DWORD
               LOCAL lpBuffer AS DWORD
          
               lBufLen = SIZEOF( szBuffer )
               lpBuffer = VARPTR( szBuffer )
               hFile = CreateFile( szFile, %GENERIC_READ, %FILE_SHARE_READ, _
               BYVAL %NULL, %OPEN_EXISTING, %FILE_ATTRIBUTE_NORMAL, 0& )
               IF hFile < > %INVALID_HANDLE_VALUE THEN
                    lToRead = GetFileSize( hFile, lToReadHigh )
                    md5_readFile_loop:
                    lResult = ReadFile( hFile, BYVAL lpBuffer, lBufLen, lLen, BYVAL %NULL )
                    IF lResult = 0 THEN GOTO md5_readFile_close
                    CALL md5_Update( ctx, lpBuffer, lLen )
                    lToRead = lToRead - lLen
                    IF lToRead = 0 THEN GOTO md5_readFile_close
                    GOTO md5_readFile_loop
                    md5_readFile_close:
                    CALL CloseHandle( hFile )
               END IF
          END SUB
          SUB test()
          
          'implements the Md5 test suite to make sure that the
          'implementation is correct
               DIM ctx AS t_MD5_CTX
               DIM szText AS ASCIIZ * 256
          
               CALL md5_Init( ctx ) 'call md5_Init each time to calculate a new digest
               szText = ""
               CALL md5_Update( ctx, VARPTR( szText ), LEN( szText ))
               ?( "Got:       " + LCASE$( md5_Digest( ctx )))
               ?( "Expected:  d41d8cd98f00b204e9800998ecf8427e" )
               CALL md5_Init( ctx ) 'call md5_Init each time to calculate a new digest
               szText = "a"
               CALL md5_Update( ctx, VARPTR( szText ), LEN( szText ))
               ?( "Got:       " + LCASE$( md5_Digest( ctx )))
               ?( "Expected:  0cc175b9c0f1b6a831c399e269772661" )
               CALL md5_Init( ctx ) 'call md5_Init each time to calculate a new digest
               szText = "abc"
               CALL md5_Update( ctx, VARPTR( szText ), LEN( szText ))
               ?( "Got:       " + LCASE$( md5_Digest( ctx )))
               ?( "Expected:  900150983cd24fb0d6963f7d28e17f72" )
               CALL md5_Init( ctx ) 'call md5_Init each time to calculate a new digest
               szText = "message digest"
               CALL md5_Update( ctx, VARPTR( szText ), LEN( szText ))
               ?( "Got:       " + LCASE$( md5_Digest( ctx )))
               ?( "Expected:  f96b697d7cb7938d525a2f31aaf161d0" )
               CALL md5_Init( ctx ) 'call md5_Init each time to calculate a new digest
               szText = "abcdefghijklmnopqrstuvwxyz"
               CALL md5_Update( ctx, VARPTR( szText ), LEN( szText ))
               ?( "Got:       " + LCASE$( md5_Digest( ctx )))
               ?( "Expected:  c3fcd3d76192e4007dfb496cca67e13b" )
               CALL md5_Init( ctx ) 'call md5_Init each time to calculate a new digest
               szText = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
               CALL md5_Update( ctx, VARPTR( szText ), LEN( szText ))
               ?( "Got:       " + LCASE$( md5_Digest( ctx )))
               ?( "Expected:  d174ab98d277d9f5a5611c2c9f419d9f" )
               CALL md5_Init( ctx ) 'call md5_Init each time to calculate a new digest
               szText = "12345678901234567890123456789012345678901234567890123456789012345678901234567890"
               CALL md5_Update( ctx, VARPTR( szText ), LEN( szText ))
               ?( "Got:       " + LCASE$( md5_Digest( ctx )))
               ?( "Expected:  57edf4a22be3c955ac49da2e2107b67a" )
          
          END SUB
          FUNCTION PBMAIN() AS LONG
               CALL Test()
               CALL testfile()
          
              ? "Done press any key."
                 WAITKEY$
          
          END FUNCTION
          SUB testfile()
          LOCAL szText         AS ASCIIZ*256
          LOCAL ctx            AS t_MD5_CTX
          
              CALL md5_Init(ctx) 'call md5_Init each time to calculate a new digest
          
              CALL    md5_readFile(ctx,"C:\temp\u.iso")    '-----------------your test file
          
              CALL md5_Update(ctx,VARPTR(szText),LEN(szText))
          
              ?("MD5= "+LCASE$(md5_Digest(ctx)))
          
          END SUB
          
          SUB md5_Transform( BYREF ctx AS t_MD5_CTX, BYVAL bBuf AS DWORD PTR )
               #DEBUG CODE OFF
               LOCAL a AS DWORD
               LOCAL b AS DWORD
               LOCAL c AS DWORD
               LOCAL d AS DWORD
          
               a = ctx.lState( 0 )
               b = ctx.lState( 1 )
               c = ctx.lState( 2 )
               d = ctx.lState( 3 )
          
          
               #ALIGN 4
          
               ! mov ecx,b
               ! mov edx,c
               ! and edx,ecx
               ! not ecx
               ! mov eax,d
               ! and ecx,eax
               ! or ecx,edx
               ! mov eax,a
               ! add eax,ecx
               ! add eax,&Hd76aa478
               ! mov ebx,bBuf
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov a,eax
               ! rol eax,%S11
               ! mov a,eax
               ! mov ebx,b
               ! add eax,ebx
               ! mov a,eax
               ! mov ecx,a
               ! mov edx,b
               ! and edx,ecx
               ! not ecx
               ! mov eax,c
               ! and ecx,eax
               ! or ecx,edx
               ! mov eax,d
               ! add eax,ecx
               ! add eax,&He8c7b756
               ! mov ebx,bBuf
               ! add ebx,4
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov d,eax
               ! rol eax,%S12
               ! mov d,eax
               ! mov ebx,a
               ! add eax,ebx
               ! mov d,eax
               ! mov ecx,d
               ! mov edx,a
               ! and edx,ecx
               ! not ecx
               ! mov eax,b
               ! and ecx,eax
               ! or ecx,edx
               ! mov eax,c
               ! add eax,ecx
               ! add eax,&H242070db
               ! mov ebx,bBuf
               ! add ebx,8
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov c,eax
               ! rol eax,%S13
               ! mov c,eax
               ! mov ebx,d
               ! add eax,ebx
               ! mov c,eax
               ! mov ecx,c
               ! mov edx,d
               ! and edx,ecx
               ! not ecx
               ! mov eax,a
               ! and ecx,eax
               ! or ecx,edx
               ! mov eax,b
               ! add eax,ecx
               ! add eax,&Hc1bdceee
               ! mov ebx,bBuf
               ! add ebx,12
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov b,eax
               ! rol eax,%S14
               ! mov b,eax
               ! mov ebx,c
               ! add eax,ebx
               ! mov b,eax
               ! mov ecx,b
               ! mov edx,c
               ! and edx,ecx
               ! not ecx
               ! mov eax,d
               ! and ecx,eax
               ! or ecx,edx
               ! mov eax,a
               ! add eax,ecx
               ! add eax,&Hf57c0faf
               ! mov ebx,bBuf
               ! add ebx,16
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov a,eax
               ! rol eax,%S11
               ! mov a,eax
               ! mov ebx,b
               ! add eax,ebx
               ! mov a,eax
               ! mov ecx,a
               ! mov edx,b
               ! and edx,ecx
               ! not ecx
               ! mov eax,c
               ! and ecx,eax
               ! or ecx,edx
               ! mov eax,d
               ! add eax,ecx
               ! add eax,&H4787c62a
               ! mov ebx,bBuf
               ! add ebx,20
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov d,eax
               ! rol eax,%S12
               ! mov d,eax
               ! mov ebx,a
               ! add eax,ebx
               ! mov d,eax
               ! mov ecx,d
               ! mov edx,a
               ! and edx,ecx
               ! not ecx
               ! mov eax,b
               ! and ecx,eax
               ! or ecx,edx
               ! mov eax,c
               ! add eax,ecx
               ! add eax,&Ha8304613
               ! mov ebx,bBuf
               ! add ebx,24
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov c,eax
               ! rol eax,%S13
               ! mov c,eax
               ! mov ebx,d
               ! add eax,ebx
               ! mov c,eax
               ! mov ecx,c
               ! mov edx,d
               ! and edx,ecx
               ! not ecx
               ! mov eax,a
               ! and ecx,eax
               ! or ecx,edx
               ! mov eax,b
               ! add eax,ecx
               ! add eax,&Hfd469501
               ! mov ebx,bBuf
               ! add ebx,28
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov b,eax
               ! rol eax,%S14
               ! mov b,eax
               ! mov ebx,c
               ! add eax,ebx
               ! mov b,eax
               ! mov ecx,b
               ! mov edx,c
               ! and edx,ecx
               ! not ecx
               ! mov eax,d
               ! and ecx,eax
               ! or ecx,edx
               ! mov eax,a
               ! add eax,ecx
               ! add eax,&H698098d8
               ! mov ebx,bBuf
               ! add ebx,32
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov a,eax
               ! rol eax,%S11
               ! mov a,eax
               ! mov ebx,b
               ! add eax,ebx
               ! mov a,eax
               ! mov ecx,a
               ! mov edx,b
               ! and edx,ecx
               ! not ecx
               ! mov eax,c
               ! and ecx,eax
               ! or ecx,edx
               ! mov eax,d
               ! add eax,ecx
               ! add eax,&H8b44f7af
               ! mov ebx,bBuf
               ! add ebx,36
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov d,eax
               ! rol eax,%S12
               ! mov d,eax
               ! mov ebx,a
               ! add eax,ebx
               ! mov d,eax
               ! mov ecx,d
               ! mov edx,a
               ! and edx,ecx
               ! not ecx
               ! mov eax,b
               ! and ecx,eax
               ! or ecx,edx
               ! mov eax,c
               ! add eax,ecx
               ! add eax,&Hffff5bb1
               ! mov ebx,bBuf
               ! add ebx,40
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov c,eax
               ! rol eax,%S13
               ! mov c,eax
               ! mov ebx,d
               ! add eax,ebx
               ! mov c,eax
               ! mov ecx,c
               ! mov edx,d
               ! and edx,ecx
               ! not ecx
               ! mov eax,a
               ! and ecx,eax
               ! or ecx,edx
               ! mov eax,b
               ! add eax,ecx
               ! add eax,&H895cd7be
               ! mov ebx,bBuf
               ! add ebx,44
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov b,eax
               ! rol eax,%S14
               ! mov b,eax
               ! mov ebx,c
               ! add eax,ebx
               ! mov b,eax
               ! mov ecx,b
               ! mov edx,c
               ! and edx,ecx
               ! not ecx
               ! mov eax,d
               ! and ecx,eax
               ! or ecx,edx
               ! mov eax,a
               ! add eax,ecx
               ! add eax,&H6b901122
               ! mov ebx,bBuf
               ! add ebx,48
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov a,eax
               ! rol eax,%S11
               ! mov a,eax
               ! mov ebx,b
               ! add eax,ebx
               ! mov a,eax
               ! mov ecx,a
               ! mov edx,b
               ! and edx,ecx
               ! not ecx
               ! mov eax,c
               ! and ecx,eax
               ! or ecx,edx
               ! mov eax,d
               ! add eax,ecx
               ! add eax,&Hfd987193
               ! mov ebx,bBuf
               ! add ebx,52
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov d,eax
               ! rol eax,%S12
               ! mov d,eax
               ! mov ebx,a
               ! add eax,ebx
               ! mov d,eax
               ! mov ecx,d
               ! mov edx,a
               ! and edx,ecx
               ! not ecx
               ! mov eax,b
               ! and ecx,eax
               ! or ecx,edx
               ! mov eax,c
               ! add eax,ecx
               ! add eax,&Ha679438e
               ! mov ebx,bBuf
               ! add ebx,56
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov c,eax
               ! rol eax,%S13
               ! mov c,eax
               ! mov ebx,d
               ! add eax,ebx
               ! mov c,eax
               ! mov ecx,c
               ! mov edx,d
               ! and edx,ecx
               ! not ecx
               ! mov eax,a
               ! and ecx,eax
               ! or ecx,edx
               ! mov eax,b
               ! add eax,ecx
               ! add eax,&H49b40821
               ! mov ebx,bBuf
               ! add ebx,60
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov b,eax
               ! rol eax,%S14
               ! mov b,eax
               ! mov ebx,c
               ! add eax,ebx
               ! mov b,eax
               ! mov ecx,d
               ! mov edx,b
               ! and edx,ecx
               ! not ecx
               ! mov eax,c
               ! and ecx,eax
               ! or ecx,edx
               ! mov eax,a
               ! add eax,ecx
               ! add eax,&Hf61e2562
               ! mov ebx,bBuf
               ! add ebx,4
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov a,eax
               ! rol eax,%S21
               ! mov a,eax
               ! mov ebx,b
               ! add eax,ebx
               ! mov a,eax
               ! mov ecx,c
               ! mov edx,a
               ! and edx,ecx
               ! not ecx
               ! mov eax,b
               ! and ecx,eax
               ! or ecx,edx
               ! mov eax,d
               ! add eax,ecx
               ! add eax,&Hc040b340
               ! mov ebx,bBuf
               ! add ebx,24
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov d,eax
               ! rol eax,%S22
               ! mov d,eax
               ! mov ebx,a
               ! add eax,ebx
               ! mov d,eax
               ! mov ecx,b
               ! mov edx,d
               ! and edx,ecx
               ! not ecx
               ! mov eax,a
               ! and ecx,eax
               ! or ecx,edx
               ! mov eax,c
               ! add eax,ecx
               ! add eax,&H265e5a51
               ! mov ebx,bBuf
               ! add ebx,44
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov c,eax
               ! rol eax,%S23
               ! mov c,eax
               ! mov ebx,d
               ! add eax,ebx
               ! mov c,eax
               ! mov ecx,a
               ! mov edx,c
               ! and edx,ecx
               ! not ecx
               ! mov eax,d
               ! and ecx,eax
               ! or ecx,edx
               ! mov eax,b
               ! add eax,ecx
               ! add eax,&He9b6c7aa
               ! mov ebx,bBuf
               ! add ebx,0
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov b,eax
               ! rol eax,%S24
               ! mov b,eax
               ! mov ebx,c
               ! add eax,ebx
               ! mov b,eax
               ! mov ecx,d
               ! mov edx,b
               ! and edx,ecx
               ! not ecx
               ! mov eax,c
               ! and ecx,eax
               ! or ecx,edx
               ! mov eax,a
               ! add eax,ecx
               ! add eax,&Hd62f105d
               ! mov ebx,bBuf
               ! add ebx,20
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov a,eax
               ! rol eax,%S21
               ! mov a,eax
               ! mov ebx,b
               ! add eax,ebx
               ! mov a,eax
               ! mov ecx,c
               ! mov edx,a
               ! and edx,ecx
               ! not ecx
               ! mov eax,b
               ! and ecx,eax
               ! or ecx,edx
               ! mov eax,d
               ! add eax,ecx
               ! add eax,&H2441453
               ! mov ebx,bBuf
               ! add ebx,40
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov d,eax
               ! rol eax,%S22
               ! mov d,eax
               ! mov ebx,a
               ! add eax,ebx
               ! mov d,eax
               ! mov ecx,b
               ! mov edx,d
               ! and edx,ecx
               ! not ecx
               ! mov eax,a
               ! and ecx,eax
               ! or ecx,edx
               ! mov eax,c
               ! add eax,ecx
               ! add eax,&Hd8a1e681
               ! mov ebx,bBuf
               ! add ebx,60
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov c,eax
               ! rol eax,%S23
               ! mov c,eax
               ! mov ebx,d
               ! add eax,ebx
               ! mov c,eax
               ! mov ecx,a
               ! mov edx,c
               ! and edx,ecx
               ! not ecx
               ! mov eax,d
               ! and ecx,eax
               ! or ecx,edx
               ! mov eax,b
               ! add eax,ecx
               ! add eax,&He7d3fbc8
               ! mov ebx,bBuf
               ! add ebx,16
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov b,eax
               ! rol eax,%S24
               ! mov b,eax
               ! mov ebx,c
               ! add eax,ebx
               ! mov b,eax
               ! mov ecx,d
               ! mov edx,b
               ! and edx,ecx
               ! not ecx
               ! mov eax,c
               ! and ecx,eax
               ! or ecx,edx
               ! mov eax,a
               ! add eax,ecx
               ! add eax,&H21e1cde6
               ! mov ebx,bBuf
               ! add ebx,36
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov a,eax
               ! rol eax,%S21
               ! mov a,eax
               ! mov ebx,b
               ! add eax,ebx
               ! mov a,eax
               ! mov ecx,c
               ! mov edx,a
               ! and edx,ecx
               ! not ecx
               ! mov eax,b
               ! and ecx,eax
               ! or ecx,edx
               ! mov eax,d
               ! add eax,ecx
               ! add eax,&Hc33707d6
               ! mov ebx,bBuf
               ! add ebx,56
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov d,eax
               ! rol eax,%S22
               ! mov d,eax
               ! mov ebx,a
               ! add eax,ebx
               ! mov d,eax
               ! mov ecx,b
               ! mov edx,d
               ! and edx,ecx
               ! not ecx
               ! mov eax,a
               ! and ecx,eax
               ! or ecx,edx
               ! mov eax,c
               ! add eax,ecx
               ! add eax,&Hf4d50d87
               ! mov ebx,bBuf
               ! add ebx,12
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov c,eax
               ! rol eax,%S23
               ! mov c,eax
               ! mov ebx,d
               ! add eax,ebx
               ! mov c,eax
               ! mov ecx,a
               ! mov edx,c
               ! and edx,ecx
               ! not ecx
               ! mov eax,d
               ! and ecx,eax
               ! or ecx,edx
               ! mov eax,b
               ! add eax,ecx
               ! add eax,&H455a14ed
               ! mov ebx,bBuf
               ! add ebx,32
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov b,eax
               ! rol eax,%S24
               ! mov b,eax
               ! mov ebx,c
               ! add eax,ebx
               ! mov b,eax
               ! mov ecx,d
               ! mov edx,b
               ! and edx,ecx
               ! not ecx
               ! mov eax,c
               ! and ecx,eax
               ! or ecx,edx
               ! mov eax,a
               ! add eax,ecx
               ! add eax,&Ha9e3e905
               ! mov ebx,bBuf
               ! add ebx,52
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov a,eax
               ! rol eax,%S21
               ! mov a,eax
               ! mov ebx,b
               ! add eax,ebx
               ! mov a,eax
               ! mov ecx,c
               ! mov edx,a
               ! and edx,ecx
               ! not ecx
               ! mov eax,b
               ! and ecx,eax
               ! or ecx,edx
               ! mov eax,d
               ! add eax,ecx
               ! add eax,&Hfcefa3f8
               ! mov ebx,bBuf
               ! add ebx,8
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov d,eax
               ! rol eax,%S22
               ! mov d,eax
               ! mov ebx,a
               ! add eax,ebx
               ! mov d,eax
               ! mov ecx,b
               ! mov edx,d
               ! and edx,ecx
               ! not ecx
               ! mov eax,a
               ! and ecx,eax
               ! or ecx,edx
               ! mov eax,c
               ! add eax,ecx
               ! add eax,&H676f02d9
               ! mov ebx,bBuf
               ! add ebx,28
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov c,eax
               ! rol eax,%S23
               ! mov c,eax
               ! mov ebx,d
               ! add eax,ebx
               ! mov c,eax
               ! mov ecx,a
               ! mov edx,c
               ! and edx,ecx
               ! not ecx
               ! mov eax,d
               ! and ecx,eax
               ! or ecx,edx
               ! mov eax,b
               ! add eax,ecx
               ! add eax,&H8d2a4c8a
               ! mov ebx,bBuf
               ! add ebx,48
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov b,eax
               ! rol eax,%S24
               ! mov b,eax
               ! mov ebx,c
               ! add eax,ebx
               ! mov b,eax
               ! mov eax,b
               ! mov edx,c
               ! xor eax,edx
               ! xor eax,d
               ! add eax,a
               ! add eax,&Hfffa3942
               ! mov ebx,bBuf
               ! add ebx,20
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov a,eax
               ! rol eax,%S31
               ! mov a,eax
               ! mov ebx,b
               ! add eax,ebx
               ! mov a,eax
               ! mov eax,a
               ! mov edx,b
               ! xor eax,edx
               ! xor eax,c
               ! add eax,d
               ! add eax,&H8771f681
               ! mov ebx,bBuf
               ! add ebx,32
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov d,eax
               ! rol eax,%S32
               ! mov d,eax
               ! mov ebx,a
               ! add eax,ebx
               ! mov d,eax
               ! mov eax,d
               ! mov edx,a
               ! xor eax,edx
               ! xor eax,b
               ! add eax,c
               ! add eax,&H6d9d6122
               ! mov ebx,bBuf
               ! add ebx,44
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov c,eax
               ! rol eax,%S33
               ! mov c,eax
               ! mov ebx,d
               ! add eax,ebx
               ! mov c,eax
               ! mov eax,c
               ! mov edx,d
               ! xor eax,edx
               ! xor eax,a
               ! add eax,b
               ! add eax,&Hfde5380c
               ! mov ebx,bBuf
               ! add ebx,56
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov b,eax
               ! rol eax,%S34
               ! mov b,eax
               ! mov ebx,c
               ! add eax,ebx
               ! mov b,eax
               ! mov eax,b
               ! mov edx,c
               ! xor eax,edx
               ! xor eax,d
               ! add eax,a
               ! add eax,&Ha4beea44
               ! mov ebx,bBuf
               ! add ebx,4
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov a,eax
               ! rol eax,%S31
               ! mov a,eax
               ! mov ebx,b
               ! add eax,ebx
               ! mov a,eax
               ! mov eax,a
               ! mov edx,b
               ! xor eax,edx
               ! xor eax,c
               ! add eax,d
               ! add eax,&H4bdecfa9
               ! mov ebx,bBuf
               ! add ebx,16
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov d,eax
               ! rol eax,%S32
               ! mov d,eax
               ! mov ebx,a
               ! add eax,ebx
               ! mov d,eax
               ! mov eax,d
               ! mov edx,a
               ! xor eax,edx
               ! xor eax,b
               ! add eax,c
               ! add eax,&Hf6bb4b60
               ! mov ebx,bBuf
               ! add ebx,28
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov c,eax
               ! rol eax,%S33
               ! mov c,eax
               ! mov ebx,d
               ! add eax,ebx
               ! mov c,eax
               ! mov eax,c
               ! mov edx,d
               ! xor eax,edx
               ! xor eax,a
               ! add eax,b
               ! add eax,&Hbebfbc70
               ! mov ebx,bBuf
               ! add ebx,40
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov b,eax
               ! rol eax,%S34
               ! mov b,eax
               ! mov ebx,c
               ! add eax,ebx
               ! mov b,eax
               ! mov eax,b
               ! mov edx,c
               ! xor eax,edx
               ! xor eax,d
               ! add eax,a
               ! add eax,&H289b7ec6
               ! mov ebx,bBuf
               ! add ebx,52
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov a,eax
               ! rol eax,%S31
               ! mov a,eax
               ! mov ebx,b
               ! add eax,ebx
               ! mov a,eax
               ! mov eax,a
               ! mov edx,b
               ! xor eax,edx
               ! xor eax,c
               ! add eax,d
               ! add eax,&Heaa127fa
               ! mov ebx,bBuf
               ! add ebx,0
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov d,eax
               ! rol eax,%S32
               ! mov d,eax
               ! mov ebx,a
               ! add eax,ebx
               ! mov d,eax
               ! mov eax,d
               ! mov edx,a
               ! xor eax,edx
               ! xor eax,b
               ! add eax,c
               ! add eax,&Hd4ef3085
               ! mov ebx,bBuf
               ! add ebx,12
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov c,eax
               ! rol eax,%S33
               ! mov c,eax
               ! mov ebx,d
               ! add eax,ebx
               ! mov c,eax
               ! mov eax,c
               ! mov edx,d
               ! xor eax,edx
               ! xor eax,a
               ! add eax,b
               ! add eax,&H4881d05
               ! mov ebx,bBuf
               ! add ebx,24
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov b,eax
               ! rol eax,%S34
               ! mov b,eax
               ! mov ebx,c
               ! add eax,ebx
               ! mov b,eax
               ! mov eax,b
               ! mov edx,c
               ! xor eax,edx
               ! xor eax,d
               ! add eax,a
               ! add eax,&Hd9d4d039
               ! mov ebx,bBuf
               ! add ebx,36
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov a,eax
               ! rol eax,%S31
               ! mov a,eax
               ! mov ebx,b
               ! add eax,ebx
               ! mov a,eax
               ! mov eax,a
               ! mov edx,b
               ! xor eax,edx
               ! xor eax,c
               ! add eax,d
               ! add eax,&He6db99e5
               ! mov ebx,bBuf
               ! add ebx,48
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov d,eax
               ! rol eax,%S32
               ! mov d,eax
               ! mov ebx,a
               ! add eax,ebx
               ! mov d,eax
               ! mov eax,d
               ! mov edx,a
               ! xor eax,edx
               ! xor eax,b
               ! add eax,c
               ! add eax,&H1fa27cf8
               ! mov ebx,bBuf
               ! add ebx,60
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov c,eax
               ! rol eax,%S33
               ! mov c,eax
               ! mov ebx,d
               ! add eax,ebx
               ! mov c,eax
               ! mov eax,c
               ! mov edx,d
               ! xor eax,edx
               ! xor eax,a
               ! add eax,b
               ! add eax,&Hc4ac5665
               ! mov ebx,bBuf
               ! add ebx,8
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov b,eax
               ! rol eax,%S34
               ! mov b,eax
               ! mov ebx,c
               ! add eax,ebx
               ! mov b,eax
               ! mov edx,d
               ! not edx
               ! mov ebx,b
               ! or edx,ebx
               ! mov eax,c
               ! xor eax,edx
               ! add eax,a
               ! add eax,&Hf4292244
               ! mov ebx,bBuf
               ! add ebx,0
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov a,eax
               ! rol eax,%S41
               ! mov a,eax
               ! mov ebx,b
               ! add eax,ebx
               ! mov a,eax
               ! mov edx,c
               ! not edx
               ! mov ebx,a
               ! or edx,ebx
               ! mov eax,b
               ! xor eax,edx
               ! add eax,d
               ! add eax,&H432aff97
               ! mov ebx,bBuf
               ! add ebx,28
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov d,eax
               ! rol eax,%S42
               ! mov d,eax
               ! mov ebx,a
               ! add eax,ebx
               ! mov d,eax
               ! mov edx,b
               ! not edx
               ! mov ebx,d
               ! or edx,ebx
               ! mov eax,a
               ! xor eax,edx
               ! add eax,c
               ! add eax,&Hab9423a7
               ! mov ebx,bBuf
               ! add ebx,56
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov c,eax
               ! rol eax,%S43
               ! mov c,eax
               ! mov ebx,d
               ! add eax,ebx
               ! mov c,eax
               ! mov edx,a
               ! not edx
               ! mov ebx,c
               ! or edx,ebx
               ! mov eax,d
               ! xor eax,edx
               ! add eax,b
               ! add eax,&Hfc93a039
               ! mov ebx,bBuf
               ! add ebx,20
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov b,eax
               ! rol eax,%S44
               ! mov b,eax
               ! mov ebx,c
               ! add eax,ebx
               ! mov b,eax
               ! mov edx,d
               ! not edx
               ! mov ebx,b
               ! or edx,ebx
               ! mov eax,c
               ! xor eax,edx
               ! add eax,a
               ! add eax,&H655b59c3
               ! mov ebx,bBuf
               ! add ebx,48
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov a,eax
               ! rol eax,%S41
               ! mov a,eax
               ! mov ebx,b
               ! add eax,ebx
               ! mov a,eax
               ! mov edx,c
               ! not edx
               ! mov ebx,a
               ! or edx,ebx
               ! mov eax,b
               ! xor eax,edx
               ! add eax,d
               ! add eax,&H8f0ccc92
               ! mov ebx,bBuf
               ! add ebx,12
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov d,eax
               ! rol eax,%S42
               ! mov d,eax
               ! mov ebx,a
               ! add eax,ebx
               ! mov d,eax
               ! mov edx,b
               ! not edx
               ! mov ebx,d
               ! or edx,ebx
               ! mov eax,a
               ! xor eax,edx
               ! add eax,c
               ! add eax,&Hffeff47d
               ! mov ebx,bBuf
               ! add ebx,40
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov c,eax
               ! rol eax,%S43
               ! mov c,eax
               ! mov ebx,d
               ! add eax,ebx
               ! mov c,eax
               ! mov edx,a
               ! not edx
               ! mov ebx,c
               ! or edx,ebx
               ! mov eax,d
               ! xor eax,edx
               ! add eax,b
               ! add eax,&H85845dd1
               ! mov ebx,bBuf
               ! add ebx,4
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov b,eax
               ! rol eax,%S44
               ! mov b,eax
               ! mov ebx,c
               ! add eax,ebx
               ! mov b,eax
               ! mov edx,d
               ! not edx
               ! mov ebx,b
               ! or edx,ebx
               ! mov eax,c
               ! xor eax,edx
               ! add eax,a
               ! add eax,&H6fa87e4f
               ! mov ebx,bBuf
               ! add ebx,32
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov a,eax
               ! rol eax,%S41
               ! mov a,eax
               ! mov ebx,b
               ! add eax,ebx
               ! mov a,eax
               ! mov edx,c
               ! not edx
               ! mov ebx,a
               ! or edx,ebx
               ! mov eax,b
               ! xor eax,edx
               ! add eax,d
               ! add eax,&Hfe2ce6e0
               ! mov ebx,bBuf
               ! add ebx,60
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov d,eax
               ! rol eax,%S42
               ! mov d,eax
               ! mov ebx,a
               ! add eax,ebx
               ! mov d,eax
               ! mov edx,b
               ! not edx
               ! mov ebx,d
               ! or edx,ebx
               ! mov eax,a
               ! xor eax,edx
               ! add eax,c
               ! add eax,&Ha3014314
               ! mov ebx,bBuf
               ! add ebx,24
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov c,eax
               ! rol eax,%S43
               ! mov c,eax
               ! mov ebx,d
               ! add eax,ebx
               ! mov c,eax
               ! mov edx,a
               ! not edx
               ! mov ebx,c
               ! or edx,ebx
               ! mov eax,d
               ! xor eax,edx
               ! add eax,b
               ! add eax,&H4e0811a1
               ! mov ebx,bBuf
               ! add ebx,52
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov b,eax
               ! rol eax,%S44
               ! mov b,eax
               ! mov ebx,c
               ! add eax,ebx
               ! mov b,eax
               ! mov edx,d
               ! not edx
               ! mov ebx,b
               ! or edx,ebx
               ! mov eax,c
               ! xor eax,edx
               ! add eax,a
               ! add eax,&Hf7537e82
               ! mov ebx,bBuf
               ! add ebx,16
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov a,eax
               ! rol eax,%S41
               ! mov a,eax
               ! mov ebx,b
               ! add eax,ebx
               ! mov a,eax
               ! mov edx,c
               ! not edx
               ! mov ebx,a
               ! or edx,ebx
               ! mov eax,b
               ! xor eax,edx
               ! add eax,d
               ! add eax,&Hbd3af235
               ! mov ebx,bBuf
               ! add ebx,44
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov d,eax
               ! rol eax,%S42
               ! mov d,eax
               ! mov ebx,a
               ! add eax,ebx
               ! mov d,eax
               ! mov edx,b
               ! not edx
               ! mov ebx,d
               ! or edx,ebx
               ! mov eax,a
               ! xor eax,edx
               ! add eax,c
               ! add eax,&H2ad7d2bb
               ! mov ebx,bBuf
               ! add ebx,8
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov c,eax
               ! rol eax,%S43
               ! mov c,eax
               ! mov ebx,d
               ! add eax,ebx
               ! mov c,eax
               ! mov edx,a
               ! not edx
               ! mov ebx,c
               ! or edx,ebx
               ! mov eax,d
               ! xor eax,edx
               ! add eax,b
               ! add eax,&Heb86d391
               ! mov ebx,bBuf
               ! add ebx,36
               ! mov ebx,[ebx]
               ! add eax,ebx
               ! mov b,eax
               ! rol eax,%S44
               ! mov b,eax
               ! mov ebx,c
               ! add eax,ebx
               ! mov b,eax
               ctx.lState( 0 ) = ctx.lState( 0 ) + a
               ctx.lState( 1 ) = ctx.lState( 1 ) + b
               ctx.lState( 2 ) = ctx.lState( 2 ) + c
               ctx.lState( 3 ) = ctx.lState( 3 ) + d
          END SUB

          Comment


          • #6
            Speed test...
            Posting code from preceding post took me 23 seconds for the forum parser to do the job.

            Test code deleted afterward...

            Comment


            • #7
              Speed test...
              Posting code from post #5 took 5 seconds for me. Likely those California folks are draining the bandwidth pool.

              Comment


              • #8
                Likely those California folks are draining the bandwidth pool.
                Hey! I had to get Disney+ ... give me a break!
                ... .... . ... . . ... ... .... . .. ... .... .. ... .... .. .... ..

                n6jah @ yahoo.com

                Comment

                Working...
                X