QuickHash Library Type Library

HMAC_Calculate

void HMAC_Calculate( [in]int nAlgID, [out]HMAC_Digest* pDigest, [ in , size_is( nSrcLength ) ] const void* pSrc, [ in ] int nSrcLength, [in,size_is( nKeyLength )]const void* pKey, [ in ]int nKeyLength );

Parameters

nAlgID

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

 pDigest

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

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

 pSrc

    [in] A continuous memory block for which to calculate the HMAC.

 nSrcLength

    [in] Length in bytes of the memory block.

 pKey

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

 nKeyLength

    [in] Length in bytes of the key.

Remarks

Calculates the HMAC for the pSrc memory block using the key specified by pKey. The HMAC is retrieved in the pDigest memory buffer.

VB Example

Private Sub MyButton_Click()   
    Dim Hmac As HMAC_Digest
    Dim MyStrData As String
    MyStrData = "Hello World!"
    Dim MyStrKey As String
    MyStrKey = "password"
    Dim nLen As Long
    nLen = Len(MyStrData)
    Dim nLenKey As Long
    nLenKey = Len(MyStrKey)
    'Convert the string to byte array
    Dim MyBinData() As Byte
    ReDim MyBinData(1 To nLen)    
    For i = 1 To nLen
        MyBinData(i) = Asc(Mid(MyStrData, i, 1))
    Next i    
    '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    
    'Get the MD5-HMAC
    HMAC_Calculate MD5_ALGID, Hmac, MyBinData(1), nLen, 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    HMAC_CalculateHex, HMAC_CalculateStr, HMAC_CalculateStrHex, QHASH_ConvertToHex


 

 

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