summaryrefslogtreecommitdiffstats
path: root/docs/content/en/functions/crypto
diff options
context:
space:
mode:
Diffstat (limited to 'docs/content/en/functions/crypto')
-rw-r--r--docs/content/en/functions/crypto/FNV32a.md18
-rw-r--r--docs/content/en/functions/crypto/HMAC.md27
-rw-r--r--docs/content/en/functions/crypto/MD5.md22
-rw-r--r--docs/content/en/functions/crypto/SHA1.md16
-rw-r--r--docs/content/en/functions/crypto/SHA256.md16
-rw-r--r--docs/content/en/functions/crypto/_index.md7
6 files changed, 106 insertions, 0 deletions
diff --git a/docs/content/en/functions/crypto/FNV32a.md b/docs/content/en/functions/crypto/FNV32a.md
new file mode 100644
index 000000000..03bcc57e7
--- /dev/null
+++ b/docs/content/en/functions/crypto/FNV32a.md
@@ -0,0 +1,18 @@
+---
+title: crypto.FNV32a
+description: Returns the 32-bit FNV (Fowler-Noll-Vo) non-cryptographic hash of the given string.
+categories: []
+keywords: []
+params:
+ functions_and_methods:
+ aliases: []
+ returnType: int
+ signatures: [crypto.FNV32a STRING]
+expiryDate: 2026-07-31 # deprecated 2024-07-31 in v0.129.0
+---
+
+{{< deprecated-in 0.129.0 >}}
+Use [`hash.FNV32a`] instead.
+
+[`hash.FNV32a`]: /functions/hash/FNV32a/
+{{< /deprecated-in >}}
diff --git a/docs/content/en/functions/crypto/HMAC.md b/docs/content/en/functions/crypto/HMAC.md
new file mode 100644
index 000000000..5929826dd
--- /dev/null
+++ b/docs/content/en/functions/crypto/HMAC.md
@@ -0,0 +1,27 @@
+---
+title: crypto.HMAC
+description: Returns a cryptographic hash that uses a key to sign a message.
+categories: []
+keywords: []
+params:
+ functions_and_methods:
+ aliases: [hmac]
+ returnType: string
+ signatures: ['crypto.HMAC HASH_TYPE KEY MESSAGE [ENCODING]']
+aliases: [/functions/hmac]
+---
+
+Set the `HASH_TYPE` argument to `md5`, `sha1`, `sha256`, or `sha512`.
+
+Set the optional `ENCODING` argument to either `hex` (default) or `binary`.
+
+```go-html-template
+{{ hmac "sha256" "Secret key" "Secret message" }}
+5cceb491f45f8b154e20f3b0a30ed3a6ff3027d373f85c78ffe8983180b03c84
+
+{{ hmac "sha256" "Secret key" "Secret message" "hex" }}
+5cceb491f45f8b154e20f3b0a30ed3a6ff3027d373f85c78ffe8983180b03c84
+
+{{ hmac "sha256" "Secret key" "Secret message" "binary" | base64Encode }}
+XM60kfRfixVOIPOwow7Tpv8wJ9Nz+Fx4/+iYMYCwPIQ=
+```
diff --git a/docs/content/en/functions/crypto/MD5.md b/docs/content/en/functions/crypto/MD5.md
new file mode 100644
index 000000000..89bb8cc1b
--- /dev/null
+++ b/docs/content/en/functions/crypto/MD5.md
@@ -0,0 +1,22 @@
+---
+title: crypto.MD5
+description: Hashes the given input and returns its MD5 checksum encoded to a hexadecimal string.
+categories: []
+keywords: []
+params:
+ functions_and_methods:
+ aliases: [md5]
+ returnType: string
+ signatures: [crypto.MD5 INPUT]
+aliases: [/functions/md5]
+---
+
+```go-html-template
+{{ md5 "Hello world" }} → 3e25960a79dbc69b674cd4ec67a72c62
+```
+
+This can be useful if you want to use [Gravatar](https://en.gravatar.com/) for generating a unique avatar:
+
+```html
+<img src="https://www.gravatar.com/avatar/{{ md5 "your@email.com" }}?s=100&d=identicon">
+```
diff --git a/docs/content/en/functions/crypto/SHA1.md b/docs/content/en/functions/crypto/SHA1.md
new file mode 100644
index 000000000..c80dac0a4
--- /dev/null
+++ b/docs/content/en/functions/crypto/SHA1.md
@@ -0,0 +1,16 @@
+---
+title: crypto.SHA1
+description: Hashes the given input and returns its SHA1 checksum encoded to a hexadecimal string.
+categories: []
+keywords: []
+params:
+ functions_and_methods:
+ aliases: [sha1]
+ returnType: string
+ signatures: [crypto.SHA1 INPUT]
+aliases: [/functions/sha,/functions/sha1]
+---
+
+```go-html-template
+{{ sha1 "Hello world" }} → 7b502c3a1f48c8609ae212cdfb639dee39673f5e
+```
diff --git a/docs/content/en/functions/crypto/SHA256.md b/docs/content/en/functions/crypto/SHA256.md
new file mode 100644
index 000000000..d0a66c069
--- /dev/null
+++ b/docs/content/en/functions/crypto/SHA256.md
@@ -0,0 +1,16 @@
+---
+title: crypto.SHA256
+description: Hashes the given input and returns its SHA256 checksum encoded to a hexadecimal string.
+categories: []
+keywords: []
+params:
+ functions_and_methods:
+ aliases: [sha256]
+ returnType: string
+ signatures: [crypto.SHA256 INPUT]
+aliases: [/functions/sha256]
+---
+
+```go-html-template
+{{ sha256 "Hello world" }} → 64ec88ca00b268e5ba1a35678a1b5316d212f4f366b2477232534a8aeca37f3c
+```
diff --git a/docs/content/en/functions/crypto/_index.md b/docs/content/en/functions/crypto/_index.md
new file mode 100644
index 000000000..5771630d4
--- /dev/null
+++ b/docs/content/en/functions/crypto/_index.md
@@ -0,0 +1,7 @@
+---
+title: Crypto functions
+linkTitle: crypto
+description: Use these functions to create cryptographic hashes.
+categories: []
+keywords: []
+---