ztcl::crypto hmac
Gives the HMAC of bytes with a key.
ztcl::crypto hmac ALGORITHM KEY DATA
Description
Gives the HMAC (RFC 2104) of the bytes of DATA with the bytes of KEY, on SHA-256, SHA-384, or SHA-512. The result has the length of the digest.
Arguments
| Argument | Type | Default | Description |
|---|---|---|---|
| ALGORITHM | string | required | sha256, sha384, or sha512. |
| KEY | bytes | required | The key. |
| DATA | bytes | required | The bytes to authenticate. |
Returns
The HMAC, as bytes.
Examples
Each example of this page runs after package require ztcl::crypto.
% binary encode hex [ztcl::crypto hmac sha256 Jefe {what do ya want for nothing?}]
5bdcc146bf60754e6a042426089575c75a003f089d2739839dec58b964ec3843
Errors
% ztcl::crypto hmac sha1 k d
bad algorithm "sha1": must be sha256, sha384, or sha512
-errorcode ZTCL CRYPTO ALG
% ztcl::crypto hmac sha256 k
wrong # args: should be "ztcl::crypto hmac algorithm key data"
-errorcode TCL WRONGARGS
Facts
- Capability
- None.
- Tcl release
- Tcl 9.1 and 8.6.
- Since
- ztcl 1.0.0-beta.10
- Compute cost
- One compute unit for each 4,096 bytes of the message, the data, and the key, and 64 more units for a signature command.