blob: a3dbcc2e59685077b7d6fd4d5659c7c3481b5b28 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
package crypto
import (
"crypto/rand"
"io"
"log/slog"
"os"
)
func NewSalt() [16]byte {
salt := [16]byte{}
if _, err := io.ReadFull(rand.Reader, salt[:]); err != nil {
slog.Error("crypto: failed to read salt", "error", err)
os.Exit(1)
}
return salt
}
func NewNonce() [12]byte {
nonce := [12]byte{}
if _, err := io.ReadFull(rand.Reader, nonce[:]); err != nil {
slog.Error("crypto: failed to read nonce", "error", err)
os.Exit(1)
}
return nonce
}
|