usermngmt/helper.go

16 lines
354 B
Go
Raw Normal View History

2021-11-08 04:53:03 +00:00
package usermngmt
2021-11-08 10:04:01 +00:00
2021-11-09 04:48:24 +00:00
import (
"golang.org/x/crypto/bcrypt"
)
2021-11-08 10:04:01 +00:00
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
}