feat(cryptox): 自 go-hua/common 迁入 MD5 摘要工具并独立成包

- 字符串/字节集/文件 MD5,附单元测试、examples/cryptox 例程与包 README
This commit is contained in:
2026-09-20 12:20:50 +08:00
parent c7e8eb14f8
commit f04a14d6bb
4 changed files with 121 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
// 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)
}