usermngmt/helper.go

14 lines
349 B
Go
Raw Permalink Normal View History

2021-11-08 04:53:03 +00:00
package usermngmt
2021-11-08 10:04:01 +00:00
import "golang.org/x/crypto/bcrypt"
func hashPassword(password string) string {
bytes, _ := bcrypt.GenerateFromPassword([]byte(password), passwordHashingCost)
return string(bytes)
}
func checkPasswordHash(password, hash string) bool {
err := bcrypt.CompareHashAndPassword([]byte(hash), []byte(password))
return err == nil
}