aboutsummaryrefslogtreecommitdiff
path: root/internal/crypto/salt.go
blob: 07180101d8cc132526f18fda40f197a4905ccbf6 (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
package crypto

import (
	"crypto/rand"
	"io"
)

func NewSalt() [16]byte {
	salt := [16]byte{}
	if _, err := io.ReadFull(rand.Reader, salt[:]); err != nil {
		panic("crypto: failed to read salt: " + err.Error())
	}

	return salt
}

func NewNonce() [12]byte {
	nonce := [12]byte{}
	if _, err := io.ReadFull(rand.Reader, nonce[:]); err != nil {
		panic("crypto: failed to read nonce: " + err.Error())
	}

	return nonce
}