AuThEnTiCaTiOn and clean up....

This commit is contained in:
2025-03-25 21:39:48 +00:00
parent b58a8bdb82
commit 11f031ff54
8 changed files with 127 additions and 56 deletions

13
helpers/auth.go Normal file
View File

@@ -0,0 +1,13 @@
package helpers
import "golang.org/x/crypto/bcrypt"
func HashPassword(password string) (string, error) {
bytes, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
return string(bytes), err
}
func CheckPasswordHash(hash, password string) bool {
err := bcrypt.CompareHashAndPassword([]byte(hash), []byte(password))
return err == nil
}