Sync shared snapshot from df68167

This commit is contained in:
Gabriel20xx committed 2026-08-06 16:53:48 +02:00
1 parent 588ef139a6
commit 06efc832ca
79 files changed
+10035 -3

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
package auth
import "golang.org/x/crypto/bcrypt"
// BcryptCost is kept in one place so all services use the same password
// storage policy. Existing hashes remain valid when this value is raised.
const BcryptCost = 12
// HashPassword returns a bcrypt password hash suitable for storage.
func HashPassword(password string) (string, error) {
hash, err := bcrypt.GenerateFromPassword([]byte(password), BcryptCost)
if err != nil {
return "", err
}
return string(hash), nil
}
// VerifyPassword checks a plaintext password against a stored bcrypt hash.
func VerifyPassword(hash, password string) bool {
return bcrypt.CompareHashAndPassword([]byte(hash), []byte(password)) == nil
}