aboutsummaryrefslogtreecommitdiff
path: root/internal/crypto/salt.go
diff options
context:
space:
mode:
authorishaan <contact@ishaan.cc>2026-07-12 08:07:47 +0530
committerishaan <contact@ishaan.cc>2026-07-12 08:07:47 +0530
commite9f777d8f7b8b77993f0b88032c33bbef06959c0 (patch)
tree7ad8945fcb4340b8db1ecad6f75fe2a19986667c /internal/crypto/salt.go
parent65017dfaff1376a16f4d11e76a8aa2d625e05aec (diff)
implement headers
Diffstat (limited to 'internal/crypto/salt.go')
-rw-r--r--internal/crypto/salt.go23
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
+}