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

This reverts commit c511a2e6b3.
This commit is contained in:
maxbad
2023-05-15 23:15:17 +08:00
parent c981d0b8eb
commit 64ed43b7ca
30 changed files with 98 additions and 336 deletions

View File

@@ -18,30 +18,20 @@ 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 := DecryptText(input)
password, err := gbase64.Decode([]byte(input))
if err != nil {
return err
}
if hash != gmd5.MustEncryptString(password+salt) {
password, err = encrypt.AesECBDecrypt(password, consts.RequestEncryptKey)
if err != nil {
return err
}
if hash != gmd5.MustEncryptString(string(password)+salt) {
err = gerror.New("用户密码不正确")
return
}