Files
4566704 f04a14d6bb feat(cryptox): 自 go-hua/common 迁入 MD5 摘要工具并独立成包
- 字符串/字节集/文件 MD5,附单元测试、examples/cryptox 例程与包 README
2026-09-20 12:20:50 +08:00

24 lines
534 B
Go

// cryptox 包示例:MD5 摘要(字符串、字节集、文件)
package main
import (
"fmt"
"os"
"path/filepath"
"git.zeroonesoft.cn/golib/zogo/cryptox"
)
func main() {
// 字符串 / 字节集 MD5
md5sum, _ := cryptox.GetMd5ByStr("hello")
fmt.Println("MD5(hello):", md5sum)
// 文件 MD5
path := filepath.Join(os.TempDir(), "zogo-cryptox-demo.txt")
_ = os.WriteFile(path, []byte("hello"), 0644)
fileMd5, err := cryptox.GetFileMd5(path)
fmt.Println("文件 MD5:", fileMd5, "错误:", err)
_ = os.Remove(path)
}