CryptoSys API Library Manual

MD5_FileHexHash

Creates an MD5 message digest in hexadecimal format from a file.

VBA/VB6 Syntax

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)

C/C++ Syntax

long __stdcall MD5_FileHexHash(char *szDigest, const char *szFileName, const char *szMode);

Parameters

szDigest
[out] to receive message digest.
szFileName
[in] with full path name of file.
szMode
[in] to set mode: "t" or "b"

Returns (VBA/C)

If successful, the return value is 0; otherwise it returns a non-zero error code.

.NET Equivalent

Md5.FileHexHash Method
Md5.FileTextHexHash Method

COM/ASP Equivalent

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.

Remarks

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).

Example

    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

See Also

MD5_StringHexHash MD5_BytesHexHash

[Contents] [Index]

[PREV: MD5_BytesHexHash...]   [Contents]   [Index]   
   [NEXT: MD5_HexDigest...]

Copyright © 2001-24 D.I. Management Services Pty Ltd. All rights reserved. Generated 2024-01-07T07:42:00Z.