HMAC Hex Key Ambiguity
This issue arises frequently.
Service providers often give instructions for HMAC generation using a hexadecimal HMAC key, such as:
01A0251D601FEF3305A38B124068A001CF3F099AA187DB2886314C67CDFDEBCD
This creates ambiguity because the instructions can be interpreted in two ways:
-
The HMAC key consists of the ASCII byte values of '0', '1', 'A', '0', '2', '5', etc.
(e.g.,
0x30
,0x31
,0x41
, etc.). -
The HMAC key consists of the byte values represented by the hex string
(e.g.,
0x01
,0xA0
,0x25
, etc.).
Chilkat supports both methods:
-
For interpretation #1: use
crypt.SetMacKeyString("01A0251D … 67CDFDEBCD")
-
For interpretation #2: use
crypt.SetMacKeyEncoded("01A0251D … 67CDFDEBCD", "hex")