|
QuickHash Library |
Type Library |
|
QHASH_BlockHexHMAC
BSTR QHASH_BlockHexHMAC( [ in ] int nAlgID, [ in, size_is(
nSrcLength ) ]const void* pSrc, [ in ] int nSrcLength,[
in, size_is( nKeyLength ) ]const void* pKey, [ in ] int
nKeyLength, [ in ] boolean bUpper );
Return value
The hexadecimal representation of the HMAC.
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.
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.
bUpper
[in] Uppercase flag. If bUpper
is False, the received HMAC represents a lowercase string,
otherwise it represents an uppercase string.
Remarks
Calculates the HMAC for the continuous memory block
specified by pSrc using the key specified by pKey. The digest/checksum is returned as a
hexadecimal string.
Note. If the result is an empty string call
QHASH_GetLastError
function for the error code.
VB Example
Private Sub MyButton_Click()
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
'Calculate and Show the MD5-HMAC in hexadecimal representation
MsgBox QHASH_BlockHexHMAC( MD5_ALGID, MyBinData(1), nLen, MyBinKey(1), nLenKey, True )
End Sub
|
|
Type Library Overview
| Type Library Functions
|
Useful Links | HashCalc
See Also
QHASH_BlockHMAC,
QHASH_StringHexHMAC,
QHASH_FileHexHMAC,
QHASH_GetLastError
|