Creates an MD5 message digest in hexadecimal format from a file.
Public Declare Function MD5_FileHexHash Lib "diCryptoSys.dll"
(ByVal strDigest As String, ByVal strFileName As String, ByVal strMode As String) As Long
nRet = MD5_FileHexHash(strDigest, strFileName, strMode)
long __stdcall MD5_FileHexHash(char *szDigest, const char *szFileName, const char *szMode);
If successful, the return value is 0; otherwise it returns a non-zero error code.
Md5.FileHexHash Method
Md5.FileTextHexHash Method
md5.FileHexHash
Public Function FileHexHash(ByVal strFileName As String) As String
md5.FileTextHexHash
Public Function FileHexHash(ByVal strFileName As String) As String
See md5.FileHexHash, md5.FileTextHexHash
.
szDigest must be at least 32 (API_MAX_MD5_CHARS) characters long (33 in a C program). Setting szMode equal to "t" or "T" will hash file in "text" mode treating a CR-LF pair as a single newline character. Setting szMode equal to "b" or "B" will hash file in "binary" mode treating CR-LF as two binary characters (default).
Dim nRet As Long Dim strDigest As String Dim strFileName As String strFileName = "hello.txt" ' Set strDigest to be 32 chars strDigest = String(32, " ") ' Make md5sum in text mode (treating CR-LF as single NL) nRet = MD5_FileHexHash(strDigest, strFileName, "t") Debug.Print "t " & nRet; strDigest ' Do in binary mode (treating CR-LF as two binary bytes) nRet = MD5_FileHexHash(strDigest, strFileName, "b") Debug.Print "b " & nRet; strDigest
For a 13-byte text file "hello.txt" in the default directory containing the 11 characters "hello world" followed by CR-LF this should result in output as follows:
t 0 6f5902ac237024bdd0c176cb93063dc4 b 0 a0f2a3c1dcd5b1cac71bf0c03f2ff1bd
MD5_StringHexHash
MD5_BytesHexHash