tulip/password/password.go

13 lines
329 B
Go
Raw Normal View History

2023-09-06 22:20:09 +01:00
package password
import "golang.org/x/crypto/bcrypt"
func HashPassword(password string) (string, error) {
bytes, err := bcrypt.GenerateFromPassword([]byte(password), 14)
return string(bytes), err
}
func CheckPasswordHash(hash, password string) error {
return bcrypt.CompareHashAndPassword([]byte(hash), []byte(password))
}