package crypto import ( "golang.org/x/crypto/bcrypt" ) // HashPassword creates a bcrypt hash of the password. // Reference: Chatwoot Devise bcrypt password hashing func HashPassword(password string) (string, error) { bytes, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost) return string(bytes), err } // CheckPassword verifies a password against its hash func CheckPassword(password, hash string) bool { err := bcrypt.CompareHashAndPassword([]byte(hash), []byte(password)) return err == nil }