package utils import ( "crypto/md5" "encoding/hex" "strings" ) func MD5ToUpper(data string) string { // 创建一个 MD5 哈希对象 hash := md5.New() // 写入待加密的数据 hash.Write([]byte(data)) // 获取 MD5 哈希值 hashBytes := hash.Sum(nil) // 将 MD5 哈希值转换为16进制字符串 str := hex.EncodeToString(hashBytes) return strings.ToUpper(str) } func MD5(data string) string { // 创建一个 MD5 哈希对象 hash := md5.New() // 写入待加密的数据 hash.Write([]byte(data)) // 获取 MD5 哈希值 hashBytes := hash.Sum(nil) // 将 MD5 哈希值转换为16进制字符串 return hex.EncodeToString(hashBytes) }