service.xpcool.com/common/tools/md5/md5.go
夏犀麟 8d5f2c65ae feat(common): 新增公共模块 common/tools 及项目上下文记忆体系
- common/tools 工具模块,10 个子功能:md5/cryptox/uuid/random/timex/convertx/strx/slicex/ip/filex(薄封装 GoFrame 内置组件)
- AGENTS.md 项目智能体说明书(架构、规范、命令、记忆体系索引)
- docs/change-log/2026-08-24.md 本次请求与变更记录
- .gitignore 排除 .workbuddy/;PROJECT_STRUCTURE.md 补充目录树
2026-08-24 17:18:10 +08:00

24 lines
624 B
Go

// Package md5 provides MD5 digest helpers.
package md5
import (
"github.com/gogf/gf/v2/crypto/gmd5"
)
// Md5Hex returns the MD5 digest of s as a lowercase hex string.
// The underlying error is ignored because it never fails for in-memory input.
func Md5Hex(s string) string {
h, _ := gmd5.EncryptString(s)
return h
}
// Md5Bytes returns the MD5 digest of data as a lowercase hex string.
func Md5Bytes(data []byte) (string, error) {
return gmd5.Encrypt(data)
}
// Md5File returns the MD5 digest of the local file at path as a hex string.
func Md5File(path string) (string, error) {
return gmd5.EncryptFile(path)
}