'abc' returns a hash value of 900150983cd24fb0d6963f7d28e17f72 when tested using the Windows crypto functions...

GenHash FRAME pszString,pHash
  uses edi,esi,ebx
  LOCAL dwStatus  :D
  LOCAL bResult  :D
  LOCAL hProv  :D
  LOCAL hHash  :D
  LOCAL cbRead  :D
  LOCAL rgbHash[64]  :B
  LOCAL cbHash  :D
  LOCAL rgbDigits[16]  :B

  // Generate a 16 byte MD5 HASH from the string
  mov ,"0123"
  mov ,"4567"
  mov ,"89ab"
  mov ,"cdef"

  invoke lstrlen,
  test eax,eax
  jz >>.ERRORCONTEXT
  mov ,eax

  invoke CryptAcquireContext,offset hProv,NULL,NULL,PROV_RSA_FULL,CRYPT_VERIFYCONTEXT
  test eax,eax
  jz >>.ERRORCONTEXT

  invoke CryptCreateHash,, CALG_MD5, NULL, NULL, offset hHash
  test eax,eax
  jz >>.ERRORHASH

  invoke CryptHashData,, , , NULL
  test eax,eax
  jz >>.ERROROTHER

  mov D,64
  invoke CryptGetHashParam,, HP_HASHVAL, offset rgbHash, offset cbHash, NULL
  test eax,eax
  jz >>.ERROROTHER

  // convert the hash to an MD5 string using a lookup table
  xor eax,eax
  xor edx,edx
  mov ebx,
  mov edi,offset rgbHash
  mov ecx,
  mov esi,offset rgbDigits
  :
    mov al,
    shr al,4
    mov dl,
    mov ,dl
    inc ebx
    mov al,
    and al,0fh
    mov dl,
    mov ,dl
    inc edi
    inc ebx
    dec ecx
  jnz <
  mov B,0

  invoke CryptDestroyHash
  invoke CryptReleaseContext, , NULL
  xor eax,eax
  ret

  .ERROROTHER
  invoke CryptDestroyHash

  .ERRORHASH
  invoke CryptReleaseContext, , NULL

  .ERRORCONTEXT
  invoke VirtualFree,,NULL,MEM_RELEASE
  xor eax,eax
  dec eax
  RET
ENDF
Posted on 2006-10-08 09:29:55 by donkey
i used roy|crisiscrackers MD5 to test.
"abc"="900150983cd24fb0d6963f7d28e17f72"
could someone test iblis MD5?
Posted on 2006-10-08 09:47:05 by dcskm4200
All of my tests show it matching exactly the output of the crypto functions...

IblisHash FRAME pszString, pHash
uses ebx
invoke lstrlen,
mov ebx,eax
invoke MD5.lib:MD5_Startup
invoke MD5.lib:MD5_Init, offset md5ctxt
invoke MD5.lib:MD5_Read, offset md5ctxt, , ebx
invoke MD5.lib:MD5_Digest, offset md5ctxt, offset md5hash

invoke MD5.lib:MD52StringA, offset md5hash, , 1
ret
ENDF


invoke GenHash,offset key,offset hash
PrintString(hash)
invoke IblisHash,offset key,offset hash
PrintString(hash)


Output:
Executing:
"D:\RadASM\GoAsm\Projects\ODCombo\Testhash.exe"
   
Line 101: hash = 900150983cd24fb0d6963f7d28e17f72
Line 103: hash = 900150983CD24FB0D6963F7D28E17F72
Posted on 2006-10-08 11:07:53 by donkey
I am guessing that discrepancy is due to your poor implementation..
Your code is being called whenever the editbox content is changed, which likely is more than once.. I am guessing when you type 'abc' you're in fact sending three EN_CHANGE notifications, causing the hashing functions to all be called three times..
The MD5_Init function is meant to be called just once, not multiple times, if I was a betting man I'd place my bets.
I've certainly had no problems with generating valid hashes using this lib.
Try hashing the term 'abc' from static data instead, as a one-shot deal.
Posted on 2006-10-08 11:32:09 by Homer
thanks you.
my error:"invoke MD5_Read, offset ctxt, offset bfBuffer, SIZEOF bfBuffer"

best regards
Posted on 2006-10-08 11:53:30 by dcskm4200
Hi dcskm4200,

Glad you got it worked out, I may take a look at Iblis' lib myself, I generally use the Advapi32 Cryptxxxx functions for hashes since they are reasonably fast and available in all but one version of Windows (95 1st release) but there are a few places where I could use an increase in hashing speed.

Donkey
Posted on 2006-10-08 16:16:09 by donkey
Nice to see people still using it after all these years.
And Hi again ;)


I'll have to go through my archives and see if I can find it and reupload.
Did all the attachments disappear when the board software changed?

Edit: Oops, I see I already reuploaded it in 2005
Posted on 2007-01-31 13:41:15 by iblis