This commit is contained in:
angelicatesvara07-crypto
2026-09-28 14:56:41 +07:00
parent f8214fda7d
commit 47f490f5a3
23 changed files with 881 additions and 72 deletions
+18
View File
@@ -0,0 +1,18 @@
package auth
import (
"golang.org/x/crypto/bcrypt"
)
func HashPassword(password string) (string, error) {
bytes, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
if err != nil {
return "", err
}
return string(bytes), nil
}
func CheckPassword(password, hash string) bool {
err := bcrypt.CompareHashAndPassword([]byte(hash), []byte(password))
return err == nil
}