fixed linter errors

This commit is contained in:
Bronku 2025-07-16 22:57:36 +02:00
parent d38a61307d
commit 1ae02b3bc6
15 changed files with 242 additions and 117 deletions

View file

@ -3,19 +3,23 @@ package crypto
import (
"crypto/rand"
"encoding/base64"
"log"
"golang.org/x/crypto/argon2"
)
func PasswordHash(password, salt string) string {
return string(argon2.Key([]byte(password), []byte(salt), 3, 32*1024, 4, 32))
var time uint32 = 3
var memory uint32 = 32 * 1024
var threads uint8 = 4
var length uint32 = 32
return string(argon2.Key([]byte(password), []byte(salt), time, memory, threads, length))
}
func GenerateKey() string {
key := [32]byte{}
if _, err := rand.Read(key[:]); err != nil {
log.Fatal("can't generate a valid key", err)
}
// rand.Read always panics when encountering an error, so checking it is pointless, as the program has already panicked
_, _ = rand.Read(key[:])
return base64.StdEncoding.EncodeToString(key[:])
}