2024-05-04 14:22:58 +00:00
|
|
|
package services
|
2024-02-01 15:26:17 +00:00
|
|
|
|
|
|
|
import "golang.org/x/crypto/bcrypt"
|
|
|
|
|
|
|
|
func HashPassword(raw string) string {
|
|
|
|
data, _ := bcrypt.GenerateFromPassword([]byte(raw), 12)
|
|
|
|
return string(data)
|
|
|
|
}
|
|
|
|
|
|
|
|
func VerifyPassword(text string, password string) bool {
|
|
|
|
return bcrypt.CompareHashAndPassword([]byte(password), []byte(text)) == nil
|
|
|
|
}
|