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.md22
-rw-r--r--docs/content/en/functions/crypto/HMAC.md31
-rw-r--r--docs/content/en/functions/crypto/MD5.md26
-rw-r--r--docs/content/en/functions/crypto/SHA1.md20
-rw-r--r--docs/content/en/functions/crypto/SHA256.md20
-rw-r--r--docs/content/en/functions/crypto/_index.md12
6 files changed, 131 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..5c091ebee
--- /dev/null
+++ b/docs/content/en/functions/crypto/FNV32a.md
@@ -0,0 +1,22 @@
+---
+title: crypto.FNV32a
+description: Returns the FNV (Fowler–Noll–Vo) 32 bit hash of a given string.
+categories: []
+keywords: []
+action:
+ aliases: []
+ related:
+ - functions/crypto/HMAC
+ - functions/crypto/MD5
+ - functions/crypto/SHA1
+ - functions/crypto/SHA256
+ returnType: int
+ signatures: [crypto.FNV32a STRING]
+aliases: [/functions/crypto.fnv32a]
+---
+
+This function calculates the 32 bit [FNV1a hash](https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function#FNV-1a_hash) of a given string according to the [specification](https://datatracker.ietf.org/doc/html/draft-eastlake-fnv-12):
+
+```go-html-template
+{{ crypto.FNV32a "Hello world" }} → 1498229191
+```
diff --git a/docs/content/en/functions/crypto/HMAC.md b/docs/content/en/functions/crypto/HMAC.md
new file mode 100644
index 000000000..1906689a2
--- /dev/null
+++ b/docs/content/en/functions/crypto/HMAC.md
@@ -0,0 +1,31 @@
+---
+title: crypto.HMAC
+description: Returns a cryptographic hash that uses a key to sign a message.
+categories: []
+keywords: []
+action:
+ aliases: [hmac]
+ related:
+ - functions/crypto/FNV32a
+ - functions/crypto/MD5
+ - functions/crypto/SHA1
+ - functions/crypto/SHA256
+ 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..ba44660df
--- /dev/null
+++ b/docs/content/en/functions/crypto/MD5.md
@@ -0,0 +1,26 @@
+---
+title: crypto.MD5
+description: Hashes the given input and returns its MD5 checksum encoded to a hexadecimal string.
+categories: []
+keywords: []
+action:
+ aliases: [md5]
+ related:
+ - functions/crypto/FNV32a
+ - functions/crypto/HMAC
+ - functions/crypto/SHA1
+ - functions/crypto/SHA256
+ 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..204ff0384
--- /dev/null
+++ b/docs/content/en/functions/crypto/SHA1.md
@@ -0,0 +1,20 @@
+---
+title: crypto.SHA1
+description: Hashes the given input and returns its SHA1 checksum encoded to a hexadecimal string.
+categories: []
+keywords: []
+action:
+ aliases: [sha1]
+ related:
+ - functions/crypto/FNV32a
+ - functions/crypto/HMAC
+ - functions/crypto/MD5
+ - functions/crypto/SHA256
+ 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..6fb657767
--- /dev/null
+++ b/docs/content/en/functions/crypto/SHA256.md
@@ -0,0 +1,20 @@
+---
+title: crypto.SHA256
+description: Hashes the given input and returns its SHA256 checksum encoded to a hexadecimal string.
+categories: []
+keywords: []
+action:
+ aliases: [sha256]
+ related:
+ - functions/crypto/FNV32a
+ - functions/crypto/HMAC
+ - functions/crypto/MD5
+ - functions/crypto/SHA1
+ 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..5c95aab6e
--- /dev/null
+++ b/docs/content/en/functions/crypto/_index.md
@@ -0,0 +1,12 @@
+---
+title: Crypto functions
+linkTitle: crypto
+description: Template functions to create cryptographic hashes.
+categories: []
+keywords: []
+menu:
+ docs:
+ parent: functions
+---
+
+Use these functions to create cryptographic hashes.