feat: Added chapter 6 first auth attempt

This commit is contained in:
2024-10-24 22:40:26 +02:00
parent 9603509fcd
commit e72fd2ee86
10 changed files with 125 additions and 17 deletions

12
internal/auth/auth.go Normal file
View File

@ -0,0 +1,12 @@
package auth
import "golang.org/x/crypto/bcrypt"
func HashPassword(password string) (string, error) {
hashedPassword, err := bcrypt.GenerateFromPassword([]byte(password), 10)
return string(hashedPassword), err
}
func CheckPasswordHash(password, hash string) error {
return bcrypt.CompareHashAndPassword([]byte(hash), []byte(password))
}