QuickHash Library Type Library


int QHASH_FileHMAC( [ in ]int nAlgID, [ out ]QHASH_Digest *pDigest, [ in , string ] unsigned char* pszFileName,[ in, size_is( nKeyLength ) ]const void* pKey, [ in ] int nKeyLength );

Return value

Zero if calculation is successful, otherwise nonzero.

Note. All possible return values are specified in the Error Codes List.



    [in] The ID of the hash algorithm selected for calculations. For example, nAlgID has to be set to SHA1_ALGID when you need to calculate the HMAC using SHA-1 hash algorithm.

    Note. All supported hash algorithms with their corresponding IDs are specified in the Predefined Constants List.



    [out] The memory buffer that will receive the HMAC.

    Note. All predefined types are specified in the Predefined Types List.


    [in] A null-terminated string specifying the name of the file for which to calculate the HMAC.


    [in] The key which represents a continuous memory block.


    [in] Length in bytes of the key.


Calculates the message HMAC for the file specified by pszFileName using the key specified by pKey. The HMAC is retrieved in the pDigest memory buffer.

VB Example

Private Sub MyButton_Click()
    Dim MyStrKey As String
    MyStrKey = "password"
    Dim nLenKey As Long
    nLenKey = Len(MyStrKey)
   'Convert the key to byte array
    Dim MyBinKey() As Byte
    ReDim MyBinKey(1 To nLenKey)
    For i = 1 To nLenKey
        MyBinKey(i) = Asc(Mid(MyStrKey, i, 1))
    Next i
    'Calculate the MD5-HMAC 
    Dim Hmac As QHASH_Digest
    QHASH_FileHMAC MD5_ALGID, Hmac, "C:\Test\Test.txt", MyBinKey(1), nLenKey
    'Show the hexadecimal representation of the MD5-HMAC
    MsgBox QHASH_ConvertToHex(Hmac.Value(0), MD5_DIGESTSIZE, True)
End Sub



Type Library Overview   |   Type Library Functions   |   Useful Links   |   HashCalc


See Also    QHASH_FileHexHMAC, QHASH_BlockHMAC, QHASH_StringHMAC, QHASH_ConvertToHex



Send Feedback to SlavaSoft Inc. Tell a friend about QuickHash Library