Merge commit 'e509cac533600cf4fa8382c9cdab78ddd82db688'

This commit is contained in:
Bjørn Erik Pedersen
2023-10-20 09:43:56 +02:00
298 changed files with 4568 additions and 1991 deletions

View File

@@ -0,0 +1,26 @@
---
title: crypto.FNV32a
description: Returns the FNV (FowlerNollVo) 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
```

View File

@@ -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=
```

View File

@@ -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">
```

View File

@@ -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
```

View File

@@ -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
```