aboutsummaryrefslogtreecommitdiff
path: root/internal/crypto
diff options
context:
space:
mode:
authorishaan <contact@ishaan.cc>2026-07-12 08:11:50 +0530
committerishaan <contact@ishaan.cc>2026-07-12 08:11:50 +0530
commit777497ec7972d60621dc2ec42495aa73c77dfa41 (patch)
treeb11e147f1feb35d612a84a2d624899c1b42ab23c /internal/crypto
parente9f777d8f7b8b77993f0b88032c33bbef06959c0 (diff)
go the go
Diffstat (limited to 'internal/crypto')
-rw-r--r--internal/crypto/salt.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/internal/crypto/salt.go b/internal/crypto/salt.go
index 0718010..a3dbcc2 100644
--- a/internal/crypto/salt.go
+++ b/internal/crypto/salt.go
@@ -3,12 +3,15 @@ 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 {
- panic("crypto: failed to read salt: " + err.Error())
+ slog.Error("crypto: failed to read salt", "error", err)
+ os.Exit(1)
}
return salt
@@ -17,7 +20,8 @@ func NewSalt() [16]byte {
func NewNonce() [12]byte {
nonce := [12]byte{}
if _, err := io.ReadFull(rand.Reader, nonce[:]); err != nil {
- panic("crypto: failed to read nonce: " + err.Error())
+ slog.Error("crypto: failed to read nonce", "error", err)
+ os.Exit(1)
}
return nonce