parent
6a5b54ced7
commit
39413b9a9c
@ -0,0 +1,13 @@ |
||||
package app |
||||
|
||||
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(password, hash string) bool { |
||||
err := bcrypt.CompareHashAndPassword([]byte(hash), []byte(password)) |
||||
return err == nil |
||||
} |
Loading…
Reference in new issue