tugas tabel user

This commit is contained in:
Yovan
2026-09-28 11:57:56 +07:00
parent 0fffcfab6c
commit 662aaec022
15 changed files with 835 additions and 33 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
}