优化服务退出流程,增加中间件文档

This commit is contained in:
孟帅
2023-05-15 18:37:40 +08:00
parent fdefb42253
commit c511a2e6b3
30 changed files with 335 additions and 97 deletions

View File

@@ -18,20 +18,30 @@ import (
"hotgo/utility/encrypt"
)
// DecryptText 解密文本
func DecryptText(text string) (string, error) {
str, err := gbase64.Decode([]byte(text))
if err != nil {
return "", err
}
str, err = encrypt.AesECBDecrypt(str, consts.RequestEncryptKey)
if err != nil {
return "", err
}
return string(str), nil
}
// CheckPassword 检查密码
func CheckPassword(input, salt, hash string) (err error) {
// 解密密码
password, err := gbase64.Decode([]byte(input))
password, err := DecryptText(input)
if err != nil {
return err
}
password, err = encrypt.AesECBDecrypt(password, consts.RequestEncryptKey)
if err != nil {
return err
}
if hash != gmd5.MustEncryptString(string(password)+salt) {
if hash != gmd5.MustEncryptString(password+salt) {
err = gerror.New("用户密码不正确")
return
}