feat(utils): 添加MD5密码加密功能

- 引入gmd5包用于MD5加密
- 实现Md5Password函数对密码进行MD5加密
- 处理加密过程中的错误情况
- 返回空字符串当加密失败时
main v1.0.1011
black1552 2026-03-02 14:18:31 +08:00
parent e4feed241f
commit fa756c25fe
2 changed files with 10 additions and 1 deletions

View File

@ -383,7 +383,7 @@
<entry key="file://$PROJECT_DIR$/utils/bcrypt.go"> <entry key="file://$PROJECT_DIR$/utils/bcrypt.go">
<value> <value>
<ScannedPath> <ScannedPath>
<option name="lastModified" value="1772432145996" /> <option name="lastModified" value="1772432291705" />
</ScannedPath> </ScannedPath>
</value> </value>
</entry> </entry>

View File

@ -3,6 +3,7 @@ package utils
import ( import (
"fmt" "fmt"
"github.com/gogf/gf/v2/crypto/gmd5"
"golang.org/x/crypto/bcrypt" "golang.org/x/crypto/bcrypt"
) )
@ -21,3 +22,11 @@ func ValidPassword(hashPassword, password string) error {
} }
return nil return nil
} }
func Md5Password(password string) string {
md5pass, err := gmd5.EncryptString(password)
if err != nil {
return ""
}
return md5pass
}