QuickHash Library Type Library

HMAC_Final

void HMAC_Final( [in, out]HMAC_Context* pContext, [out]HMAC_Digest* pDigest );
 

Parameters

pContext

    [in/out] A memory buffer that is used as the context.

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

 pDigest

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

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

Remarks

Call this function to retrieve the HMAC from the context specified by pContext. The HMAC is retrieved in the pDigest memory buffer.

After the HMAC_Final function is performed, the context is initialized for new calculations, as it would be called HMAC_Init again.

Note. Before the first call to HMAC_Update, HMAC_UpdateStr, HMAC_Final or HMAC_FinalHex functions, the context must be initialized with HMAC_Init or HMAC_InitKeyStr.

VB Example

Private Sub MyButton_Click()   
    Dim Context As HMAC_Context
    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    
    'Initialize the context for MD5-HMAC calculations
    HMAC_Init Context, MD5_ALGID, MyBinKey(1), nLenKey
    'Update the context with first part
    Dim nFirstLen As Long
    nFirstLen = nLen / 3
    HMAC_Update Context, MyBinData(1), nFirstLen
    'Update the context with second part
    HMAC_Update Context, MyBinData(nFirstLen + 1), nLen - nFirstLen
    'Get the MD5-HMAC
    HMAC_Final Context, Hmac 
    '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_FinalHex, HMAC_Update, HMAC_UpdateStr, HMAC_Init, HMAC_InitKeyStr, QHASH_ConvertToHex


 

 

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