13 lines
343 B
Go
13 lines
343 B
Go
|
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))
|
||
|
}
|