calculateHmac
Type: calculateHmac(content: string): APIResult<string>
This method computes the HMAC (SHA-256) of the specified content string using the secretKey
, and returns it as a hexadecimal string.
Parameters
Option | Type | Description |
---|---|---|
content | string | The string content to compute HMAC for |
Return Value
APIResult<string>
— Returns the calculated HMAC. If the operation fails, success: false
is returned with an error message.
Example Usage
TypeScript
const = .();
const = .("example-content");
if (.) {
.("HMAC:", .);
} else {
.("Error:", .);
}
Notes
- This function executes synchronously.
- If the
secretKey
is improperly configured during initialization, it may throw a runtime error.
Last updated on