This commit is contained in:
2025-07-07 20:11:59 +08:00
parent ab0fdbc447
commit 06e3aa2eb3
2009 changed files with 193082 additions and 0 deletions

View File

@ -0,0 +1,23 @@
package coryCommon
import (
"crypto/md5"
"encoding/hex"
"strings"
)
// MD5Hash 将字符串进行 MD5 加密,并返回 32 位长度的 MD5 散列值
func MD5Hash(input string) string {
// 将输入字符串转换为小写,以确保不区分大小写
input = strings.ToLower(input)
// 创建 MD5 散列对象
md5Hash := md5.New()
// 将输入字符串转换为字节数组,并传递给 MD5 散列对象
_, _ = md5Hash.Write([]byte(input))
// 计算 MD5 散列值
hashBytes := md5Hash.Sum(nil)
// 将散列值转换为 32 位的十六进制字符串
md5HashString := hex.EncodeToString(hashBytes)
return md5HashString
}