Are there any hash functions available in VBA?

Steff_DK

Registered User.
Local time
Today, 23:18
Joined
Feb 12, 2005
Messages
110
I need to hash values into a string of a fixed lenght of seemingly random characters, like MD5 or alike ...

Any function to do this in VBA?
 
CAPICOM provides MDx and SHA1 hashing easily accessible from VBA

here is SHA1 late-binding

Public Function Hash(ByVal strPlainText As String) As String
Dim obHash As Object
On Error GoTo err_Hash
Set obHash = CreateObject("CAPICOM.HashedData")
obHash.Algorithm = 0 'that's SHA1 - see CAPICOM documentation for MDx
obHash.Hash strPlainText
Hash = obHash.Value
exit_Hash:
strPlainText = ""
Set obHash = Nothing
Exit Function
err_Hash:
MsgBox Err.Number & ": " & Err.Description, vbInformation, "Hash error"
Hash = ""
Resume exit_Hash
End Function

you need CAPICOM on the machine...normally it's there already, else it's freely downloadable from M$

izy
 

Users who are viewing this thread

Back
Top Bottom