Debian Codegraph @

docs/content/en/functions/crypto/HMAC.md

raw
1 ---
2 title: crypto.HMAC
3 description: Returns a cryptographic hash that uses a key to sign a message.
4 categories: []
5 keywords: []
6 params:
7 functions_and_methods:
8 aliases: [hmac]
9 returnType: string
10 signatures: ['crypto.HMAC HASH_TYPE KEY MESSAGE [ENCODING]']
11 aliases: [/functions/hmac]
12 ---
13
14 Set the `HASH_TYPE` argument to `md5`, `sha1`, `sha256`, or `sha512`.
15
16 Set the optional `ENCODING` argument to either `hex` (default) or `binary`.
17
18 ```go-html-template
19 {{ hmac "sha256" "Secret key" "Secret message" }}
20 5cceb491f45f8b154e20f3b0a30ed3a6ff3027d373f85c78ffe8983180b03c84
21
22 {{ hmac "sha256" "Secret key" "Secret message" "hex" }}
23 5cceb491f45f8b154e20f3b0a30ed3a6ff3027d373f85c78ffe8983180b03c84
24
25 {{ hmac "sha256" "Secret key" "Secret message" "binary" | base64Encode }}
26 XM60kfRfixVOIPOwow7Tpv8wJ9Nz+Fx4/+iYMYCwPIQ=
27 ```