diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2023-10-20 09:43:56 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2023-10-20 09:43:56 +0200 |
commit | e2dd4cd05fa96a08d49b3b198edf0ccf9a94970e (patch) | |
tree | 712334f7e7a657155706f556040575bea9b7757f /docs/content/en/functions/crypto | |
parent | fd381718101a35a5f5f92d5a05b3a0c36ef50db0 (diff) | |
parent | e509cac533600cf4fa8382c9cdab78ddd82db688 (diff) |
Merge commit 'e509cac533600cf4fa8382c9cdab78ddd82db688'
Diffstat (limited to 'docs/content/en/functions/crypto')
-rw-r--r-- | docs/content/en/functions/crypto/FNV32a.md | 26 | ||||
-rw-r--r-- | docs/content/en/functions/crypto/HMAC.md | 36 | ||||
-rw-r--r-- | docs/content/en/functions/crypto/MD5.md | 32 | ||||
-rw-r--r-- | docs/content/en/functions/crypto/SHA1.md | 25 | ||||
-rw-r--r-- | docs/content/en/functions/crypto/SHA256.md | 25 |
5 files changed, 144 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..7a7fe303e --- /dev/null +++ b/docs/content/en/functions/crypto/FNV32a.md @@ -0,0 +1,26 @@ +--- +title: crypto.FNV32a +description: Returns the FNV (Fowler–Noll–Vo) 32 bit hash of a given string. +categories: [functions] +keywords: [] +menu: + docs: + parent: functions +function: + aliases: [] + returnType: int + signatures: [crypto.FNV32a STRING] +relatedFunctions: + - crypto.FNV32a + - crypto.HMAC + - crypto.MD5 + - crypto.SHA1 + - crypto.SHA256 +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..e58619b38 --- /dev/null +++ b/docs/content/en/functions/crypto/HMAC.md @@ -0,0 +1,36 @@ +--- +title: crypto.HMAC +linkTitle: hmac +description: Returns a cryptographic hash that uses a key to sign a message. +categories: [functions] +keywords: [] +menu: + docs: + parent: functions +function: + aliases: [hmac] + returnType: string + signatures: ['crypto.HMAC HASH_TYPE KEY MESSAGE [ENCODING]'] +relatedFunctions: + - crypto.FNV32a + - crypto.HMAC + - crypto.MD5 + - crypto.SHA1 + - crypto.SHA256 +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..9415e015c --- /dev/null +++ b/docs/content/en/functions/crypto/MD5.md @@ -0,0 +1,32 @@ +--- +title: crypto.MD5 +linkTitle: md5 +description: hashes the given input and returns its MD5 checksum. +categories: [functions] +keywords: [] +menu: + docs: + parent: functions +function: + aliases: [md5] + returnType: string + signatures: [crypto.MD5 INPUT] +relatedFunctions: + - crypto.FNV32a + - crypto.HMAC + - crypto.MD5 + - crypto.SHA1 + - crypto.SHA256 +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..6269efe38 --- /dev/null +++ b/docs/content/en/functions/crypto/SHA1.md @@ -0,0 +1,25 @@ +--- +title: crypto.SHA1 +linkTitle: sha1 +description: Hashes the given input and returns its SHA1 checksum. +categories: [functions] +keywords: [] +menu: + docs: + parent: functions +function: + aliases: [sha1] + returnType: string + signatures: [crypto.SHA1 INPUT] +relatedFunctions: + - crypto.FNV32a + - crypto.HMAC + - crypto.MD5 + - crypto.SHA1 + - crypto.SHA256 +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..3019432d2 --- /dev/null +++ b/docs/content/en/functions/crypto/SHA256.md @@ -0,0 +1,25 @@ +--- +title: crypto.SHA256 +linkTitle: sha256 +description: Hashes the given input and returns its SHA256 checksum. +categories: [functions] +keywords: [] +menu: + docs: + parent: functions +function: + aliases: [sha256] + returnType: string + signatures: [crypto.SHA256 INPUT] +relatedFunctions: + - crypto.FNV32a + - crypto.HMAC + - crypto.MD5 + - crypto.SHA1 + - crypto.SHA256 +aliases: [/functions/sha256] +--- + +```go-html-template +{{ sha256 "Hello world" }} → 64ec88ca00b268e5ba1a35678a1b5316d212f4f366b2477232534a8aeca37f3c +``` |