hmac - Liquid Filter Reference - 1.0.0
Filter Name | hmac |
Group | Text |
Version | 1.0.0 |
Description
Converts a string into an encrypted hash using a hash message authentication code (HMAC).
Examples
When no options are specified, it uses the SHA1 algorithm and returns a Hex digest:
{{ "String to Hash" | hmac: "secret key" }}
3fccbb2a2682817133576387047f3557f22c8f0d
When an invalid algorithm is specified, it returns an empty string:
{{ "String to Hash" | hmac: "secret key", algorithm: "FAKE" }}
Options
algorithm
Specifies the algorithm to use for the HMAC. The default is SHA1. Options are SHA, SHA1, SHA224, SHA256, SHA384, SHA512, MD5, and RIPEMD160.}
When the SHA1 algorithm is specified, it uses the SHA1 algorithm:
{{ "String to Hash" | hmac: "secret key", algorithm: "SHA1" }}
3fccbb2a2682817133576387047f3557f22c8f0d
When the SHA224 algorithm is specified, it uses the SHA224 algorithm:
{{ "String to Hash" | hmac: "secret key", algorithm: "SHA224" }}
98c04c44515392b355581ed552ab305db0b0f4151db7d94a7784c7b0
When the SHA256 algorithm is specified, it uses the SHA256 algorithm:
{{ "String to Hash" | hmac: "secret key", algorithm: "SHA256" }}
ff4550549b016f5f35796f2e844acdca73773f99c1b20550c2fd3043747be2e8
When the SHA384 algorithm is specified, it uses the SHA384 algorithm:
{{ "String to Hash" | hmac: "secret key", algorithm: "SHA384" }}
9eb3f59a5c9cdd4775c58741eb538ccdf6e9d37f1eb1dcb01baaa6a2b51a462d247c45f0a39ec3f01dfd30e78dc55278
When the SHA512 algorithm is specified, it uses the SHA512 algorithm:
{{ "String to Hash" | hmac: "secret key", algorithm: "SHA512" }}
9bae2a8a0175655b330ab916441a2d8c51c70fb3fcea095c61302b61d596d801a0922759a945e393819dbdf6e9e93b5dd730c1dfd89d939b2af634526adf7f68
When the MD5 algorithm is specified, it uses the MD5 algorithm:
{{ "String to Hash" | hmac: "secret key", algorithm: "MD5" }}
f7b8d119d8bd876bda5cc8daffd28192
When the RIPEMD160 algorithm is specified, it uses the RIPEMD160 algorithm:
{{ "String to Hash" | hmac: "secret key", algorithm: "RIPEMD160" }}
369194f21c554bfe42fc57c01b804eafe2ae2165
digest
Specifies the digest format to use to use for the HMAC. The default is Hex. Options are Base64, and Hex.
When the Hex digest is specified, it returns a hex digest:
{{ "String to Hash" | hmac: "secret key", digest: "Hex" }}
3fccbb2a2682817133576387047f3557f22c8f0d
When the Base64 digest is specified, it returns a base64 digest:
{{ "String to Hash" | hmac: "secret key", digest: "Base64" }}
P8y7KiaCgXEzV2OHBH81V/Isjw0=
Back to Liquid Reference for 1.0.0
Back to Documentation