Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a user function that creates a hash value from the contents of a
range. It uses the CryptAcqureContext and CryptCreateHash functions in the advapi32 library. These have worked splendidly on a WinXP SP2, Office 2003 system. They have worked on several other systems without trouble. I have a new computer using Windows Media Center. I loaded Office 2003, then Office 2007 keeping the Office 2003 applications. The CryptAcquireContext function returns a zero in the hProv argument instead of some non-zero long integer. This tells me that the reference to Lib advapi32 is mixed up, or there is some incompatibility between this function and Windows Media Center (which I have trouble believing). I have un-installed Office 2007, Rebooted. Repaired Office 2003 Prof. Rebooted. CryptAcquireContext hProv, ..... hProv = 0. wrong. Un-installed Office 2003. Reboot. Install Office 2003 Prof. Complete. Reboot. CryptAcquireContext hProv,.... hProv = 0. Still not working. checked advapi32.dll. Version is the same as on the Winbook, WinXP SP2, Off 2003 where it works well. it is located in the same place: C:\Windows\System32\advapi32.dll. Additionally, my Outlook will not remember my email passwords. My feeling is the registry is a mess at this point. Anyone recommend a good registry clean-up tool? I'm about to implement KB290301 "Windows installer cleanup utility" to try and go after some registration issues. "Stephen Rasey" wrote in message ... 'a Hash Function from Stephen Bullen. 'From: Stephen Bullen ) 'Subject: Hash (MD5) in Excel 'Newsgroups: microsoft.public.Excel.programming Date: 2004-02-05 12:50:20 PST 'Modified (bug fix) by Stephen Rasey June 2004 Option Explicit Declare Function CryptAcquireContext Lib "advapi32" Alias "CryptAcquireContextA" (ByRef hProv As Long, ByVal sContainer As String, _ ByVal sProvider As String, ByVal lProvType As Long, ByVal lFlags As Long) As Long Declare Function CryptCreateHash Lib "advapi32" (ByVal hProv As Long, ByVal lALG_ID As Long, _ ByVal hKey As Long, ByVal lFlags As Long, ByRef hhash As Long) As Long Declare Function CryptHashData Lib "advapi32" (ByVal hhash As Long, ByVal lDataPtr As Long, ByVal lLen As Long, ByVal lFlags As Long) As Long Declare Function CryptGetHashParam Lib "advapi32" (ByVal hhash As Long, ByVal lParam As Long, ByVal sBuffer As String, _ ByRef lLen As Long, ByVal lFlags As Long) As Long Declare Function CryptDestroyHash Lib "advapi32" (ByVal hhash As Long) As Long Declare Function CryptReleaseContext Lib "advapi32" (ByVal hProv As Long, ByVal lFlags As Long) As Long Const MS_DEF_PROV = "Microsoft Base Cryptographic Provider v1.0" Const PROV_RSA_FULL As Long = 1 Const CRYPT_NEWKEYSET As Long = 8 Const CALG_MD5 As Long = 32771 Const HP_HASHVAL As Long = 2 ' wwGetMD5Hash - GetMD5Hash (written by Stephen Bullen) modified by Stephen Rasey 040612 ' Changes: Use StrPtr and coerse all cell values to strings ' Empty cells are not ignored, but the cell number in the range ' is used to generate more data for the hash Public Function wwGetMD5Hash(rngData As Range) As String Dim hProv As Long Dim hhash As Long Dim lLen As Long Dim ocell As Range Dim baData() As Byte Dim sBuffer As String Dim vValue As String Dim vU2 As Variant Dim lresult As Long Dim lcellCounter As Long On Error GoTo E1 'Get/create a cryptography context CryptAcquireContext hProv, vbNullString, MS_DEF_PROV, PROV_RSA_FULL, 0 If hProv = 0 Then CryptAcquireContext hProv, vbNullString, MS_DEF_PROV, PROV_RSA_FULL, CRYPT_NEWKEYSET End If 'If we got one... If hProv < 0 Then 'Create an MD5 Hash CryptCreateHash hProv, CALG_MD5, 0, 0, hhash 'If that was OK... If hhash < 0 Then 'Fill it with the contents of the range (and it continues...) the full function can be found he http://www.excelsig.org/VBA/wwHash.htm -Stephen Rasey |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Text "comparison" operator for "contains" used in an "IF" Function | Excel Worksheet Functions | |||
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell | Excel Discussion (Misc queries) | |||
Working out age from "Day" "Month" "Year" | Excel Worksheet Functions | |||
Please add a "sheet" function like "row" and "column" functions | Excel Programming | |||
a button to open up "My Computer" on an excel sheet | Excel Programming |