1 Star 0 Fork 0

tomatomeatman/GolangRepository

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
Md5.go 782 Bytes
Copy Edit Raw Blame History
laowei authored 2024-07-15 17:29 +08:00 . 1
package mdutil
import (
"crypto/md5"
"encoding/hex"
"fmt"
"strings"
)
type Md5 struct{}
// 取MD5,大写
func (md Md5) Upper(str ...interface{}) string {
var build strings.Builder
for _, value := range str {
build.WriteString(fmt.Sprintf("%v", value))
}
data := []byte(build.String())
md5Ctx := md5.New()
md5Ctx.Write(data)
cipherStr := md5Ctx.Sum(nil)
result := hex.EncodeToString(cipherStr)
return strings.ToUpper(result)
}
// 取MD5小写
func (md Md5) Lower(str ...interface{}) string {
var build strings.Builder
for _, value := range str {
build.WriteString(fmt.Sprintf("%v", value))
}
data := []byte(build.String())
md5Ctx := md5.New()
md5Ctx.Write(data)
cipherStr := md5Ctx.Sum(nil)
result := hex.EncodeToString(cipherStr)
return result
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/tomatomeatman/golang-repository.git
git@gitee.com:tomatomeatman/golang-repository.git
tomatomeatman
golang-repository
GolangRepository
4ad22df043c3

Search