Hi Mike,
_CryptX.vcx is a copy of the _Crypt.vcx library where several methods were
made public that previously have been hidden. The following sample isn't
using MD5, but SHA1 which is a bit more secure.
*===========================================================================
=============
* Returns the hash value of a string.
*===========================================================================
=============
LParameter tcString
#include wincrypt.h
Local loCrypt, lcHash
* Special version of _CryptAPI that doesn't hide all methodss
loCrypt = NewObject("_CryptApi","_CryptX.vcx")
Local lnHashHandle, lnRet, lnLength, lcHash
lnHashHandle = 0
lcHash = NULL
loCrypt.CryptCreateHash( loCrypt.hProviderHandle, dnCALG_SHA, 0, 0,
@lnHashHandle )
If loCrypt.nlastapierror = 0
loCrypt.CryptHashData( m.lnHashHandle, m.tcString,
Len(m.tcString), 0 )
If loCrypt.nlastapierror = 0
Declare Long CryptGetHashParam in Win32API ;
Long hHash, ;
Long dwParam, ;
Long @pbData, ;
Long @pdwDataLen, ;
Long dwFlags
lnLength = 0
lnRet = CryptGetHashParam(m.lnHashHandle,
dnHP_HASHSIZE, @lnLength, 4, 0)
If m.lnRet # 0
Declare Long CryptGetHashParam in Win32API ;
Long hHash, ;
Long dwParam, ;
String @pbData, ;
Long @pdwDataLen, ;
Long dwFlags
lcHash = replicate( Chr(0), m.lnLength )
lnRet = CryptGetHashParam(m.lnHashHandle,
dnHP_HASHVAL, @lcHash, m.lnLength, 0)
If m.lnRet == 0
lcHash = NULL
EndIf
EndIf
EndIf
loCrypt.CryptDestroyHash( m.lnHashHandle )
EndIf
Return m.lcHash
--
Christof
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message:
http://leafe.com/archives/byMID/profox/12e8f66940654d4cb89c4c8bc0269...@fpl5
** All postings, unless explicitly stated otherwise, are the opinions of the
author, and do not constitute legal or medical advice. This statement is added
to the messages for those lawyers who are too stupid to see the obvious.