QuickHash Library Type Library

HMAC_FinalHex

void HMAC_FinalHex( [in,out]HMAC_Context* pContext,[out]HMAC_HexDigest* pDigest, [ in ]boolean bUpper );
 

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 as an ASCII null-terminated string.

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

 bUpper

    [in] Uppercase flag. If bUpper is False, the received HMAC represents a lowercase string, otherwise it represents an uppercase string.

Remarks

Call this function to retrieve the HMAC from the context specified by pContext. The HMAC is retrieved as an ASCII null-terminated hexadecimal string in the pDigest memory buffer.

After the HMAC_FinalHex 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_HexDigest

        
    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_FinalHex Context, Hmac, True
    'Show the hexadecimal representation of the digest
    MsgBox QHASH_ASCIItoBSTR(Hmac.Value(0))
End Sub

 

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

See Also    HMAC_Final, HMAC_Update, HMAC_UpdateStr, HMAC_Init, HMAC_InitKeyStr, QHASH_ASCIItoBSTR


 

 

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