add: some user api and all api desc

This commit is contained in:
wwweww
2026-02-27 19:17:01 +08:00
parent a0c720eb2f
commit 5930fb0dde
156 changed files with 9457 additions and 1086 deletions
+25
View File
@@ -0,0 +1,25 @@
package pwdUtils
import (
"golang.org/x/crypto/bcrypt"
)
const (
// bcrypt 密钥成本
bcryptCost = bcrypt.DefaultCost
)
// HashPassword 对密码进行哈希加密
func HashPassword(password string) (string, error) {
hash, err := bcrypt.GenerateFromPassword([]byte(password), bcryptCost)
if err != nil {
return "", err
}
return string(hash), nil
}
// VerifyPassword 验证密码是否正确
func VerifyPassword(hashedPassword, password string) bool {
err := bcrypt.CompareHashAndPassword([]byte(hashedPassword), []byte(password))
return err == nil
}