diff options
Diffstat (limited to 'internal/crypto/salt.go')
| -rw-r--r-- | internal/crypto/salt.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/internal/crypto/salt.go b/internal/crypto/salt.go index 5871506..0718010 100644 --- a/internal/crypto/salt.go +++ b/internal/crypto/salt.go @@ -1 +1,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 +} |