My favorite answer is that I would use the OpenSSL libraries, the HMAC function. I successfully used the OpenSSL libraries in Delphi, accepting and adapting work from M Ferrante http://www.disi.unige.it/person/FerranteM/delphiopenssl/
For other OpenSSL signatures, etc. See this link
In D2010, this is something like this (libeay32 is a unit taken from a website and slightly modified for unicode / D2010):
uses libeay32; const LIBEAY_DLL_NAME = 'libeay32.dll'; EVP_MAX_MD_SIZE = 64; function EVP_sha256: pEVP_MD; cdecl; external LIBEAY_DLL_NAME; function HMAC(evp: pEVP_MD; key: PByte; key_len: integer; data: PByte; data_len: integer; md: PByte; var md_len: integer): PByte; cdecl; external LIBEAY_DLL_NAME; function GetHMAC(const AKey, AData: string): TBytes; var key, data: TBytes; md_len: integer; res: PByte; begin OpenSSL_add_all_algorithms;
Then call it using the passphrase and data string. The result is TBytes, which can be converted as needed, for example, to Base64 using something like JclMime or a simple function like HexToString.
For an older version of Delphi, you will have to change PBytes to PChars or something similar.
Disclaimer: I do not have reference data to verify this, but it works fine!
shunty
source share