game/common/utils/password.go

15 lines
288 B
Go
Raw Normal View History

2025-06-02 01:07:35 +08:00
package utils
import (
"golang.org/x/crypto/bcrypt"
)
func Password(password string) (string, error) {
// 密码加密
hashedPassword, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
if err != nil {
return "", err
}
return string(hashedPassword), nil
}