Passport/pkg/internal/services/encrypt.go

13 lines
311 B
Go
Raw Normal View History

2024-04-20 11:04:33 +00:00
package services
2024-01-06 17:56:32 +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
}