hmac.md (969B)
1 --- 2 title: hmac 3 linktitle: hmac 4 description: Returns a cryptographic hash that uses a key to sign a message. 5 date: 2020-05-29 6 publishdate: 2020-05-29 7 lastmod: 2020-05-29 8 categories: [functions] 9 menu: 10 docs: 11 parent: "functions" 12 keywords: [hmac,checksum] 13 signature: ["crypto.HMAC HASH_TYPE KEY MESSAGE [ENCODING]","hmac HASH_TYPE KEY MESSAGE [ENCODING]" ] 14 workson: [] 15 hugoversion: 16 relatedfuncs: [hmac] 17 deprecated: false 18 aliases: [] 19 --- 20 21 Set the `HASH_TYPE` argument to `md5`, `sha1`, `sha256`, or `sha512`. 22 23 Set the optional `ENCODING` argument to either `hex` (default) or `binary`. 24 25 ```go-html-template 26 {{ hmac "sha256" "Secret key" "Secret message" }} 27 5cceb491f45f8b154e20f3b0a30ed3a6ff3027d373f85c78ffe8983180b03c84 28 29 {{ hmac "sha256" "Secret key" "Secret message" "hex" }} 30 5cceb491f45f8b154e20f3b0a30ed3a6ff3027d373f85c78ffe8983180b03c84 31 32 {{ hmac "sha256" "Secret key" "Secret message" "binary" | base64Encode }} 33 XM60kfRfixVOIPOwow7Tpv8wJ9Nz+Fx4/+iYMYCwPIQ= 34 ```