uses Hash, HMAC, HMACSHA2, Mem_Util
{...}
function HMAC_SHA256(AKey, AStr: AnsiString): String;
var
ctx: THMAC_Context;
mac: TSHA256Digest;
begin
hmac_SHA256_init(ctx, @AKey[1], Length(AKey));
hmac_SHA256_update(ctx, @AStr[1], Length(AStr));
hmac_SHA256_final(ctx, mac);
Result:=HexStr(@mac, SizeOf(TSHA256Digest));
end;