HMAC(alg, str, key)
HMAC message authentication code.
Syntax
HMAC(alg, str, key);
Arguments
| Name | Description |
|---|---|
|
alg |
A string which specifies the algorithm. |
|
str |
A string which will be calculated. |
|
key |
A string which is a secret key. |
Events
Applicable in all events.
Example
when HTTP_REQUEST {
alg = "MD5"; -- or "SHA1", "SHA256", "SHA384", "SHA512"
data = "your data"
key = "123456789ABCDEF0123456789ABCDEF\121"; -- or you can generate a key using key_gen
re = HMAC(alg, data, key);
debug("the HMAC in hex is %s\n", to_HEX(re));
}
Note:
Alg: type of hashing algorithms to use, must be MD5, SHA1, SHA256, SHA384, SHA512
Supported Version
FortiADC version 5.2.x and later.