Documentation
¶
Index ¶
- func GenerateRandUUID() (getUUID uuid.UUID)
- func GetVisitorProtocol(ctx context.Context) string
- func MakeUUIDByString(getString string) (getUUID uuid.UUID)
- func PasswordEncode(getPassword string) string
- func PasswordVerify(getPassword, getHashPassword string) bool
- func RandomString(length int) string
- func TokenRemoveBearer(getToken string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateRandUUID ¶
GenerateRandUUID
生成随机UUID ¶
用于生成一个随机 UUID,包装使用了 github.com/google/uuid 库. 生成的规则遵循 Google UUID V7 版本. 生成的 UUID 为 uuid.UUID 类型.
返回: ¶
- getUUID 生成随机的 UUID(uuid.UUID)
func GetVisitorProtocol ¶
GetVisitorProtocol
获取访问者协议 ¶
用于获取访问者使用的协议类型,返回协议类型. 返回的协议类型为 string 类型. 如果是 SSL 协议则返回 "SSL",否则返回 "TLS". 即若请求中访问协议为 HTTPS 则返回 "SSL",否则返回 "TLS". 若 context.Context 为空则返回空字符串.
参数: ¶
- ctx 请求的上下文(context.Context)
返回: ¶
- string 协议类型
func MakeUUIDByString ¶
MakeUUIDByString
通过字符串生成UUID ¶
用于通过字符串生成一个 UUID,生成的 UUID 是一个固定的值,不会随机生成.根据输入参数的内容决定返回的 UUID.
参数: ¶
- getString 传入的字符串(string)
返回: ¶
- getUUID 生成的 UUID(uuid.UUID)
func PasswordEncode ¶
PasswordEncode
密码加密 ¶
用于对密码进行加密,返回加密后的密码. 加密规则遵循 bcrypt 加密算法. 返回的密码为 string 类型. 加密方式为: base64 -> md5 -> bcrypt.
参数: ¶
- getPassword 需要加密的密码(string)
返回: ¶
- string 加密后的密码
func PasswordVerify ¶
PasswordVerify
密码验证 ¶
用于验证密码是否正确,返回验证结果. 验证规则遵循 bcrypt 加密算法. 返回的结果为 bool 类型. 验证方式为: base64 -> md5 -> bcrypt.
参数: ¶
- getPassword 原始密码(string)
- getHashPassword 需要验证的密码(string)
返回: ¶
- bool 验证结果
func RandomString ¶
RandomString
生成随机字符串 ¶
用于生成一个指定长度的随机字符串,返回生成的随机字符串. 生成的字符串为 string 类型.
参数: ¶
- length 生成的字符串长度(int)
返回: ¶
- string 生成的随机字符串
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.