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
+22
View File
@@ -0,0 +1,22 @@
# cryptox
摘要工具:字符串 / 字节集 / 文件的 MD5,返回 32 位十六进制小写。
> 迁移自 go-hua/common(原 encrypt.go)。
## 用法
```go
import "git.zeroonesoft.cn/golib/zogo/cryptox"
s, err := cryptox.GetMd5ByStr("hello") // "5d41402a..."
s, err := cryptox.GetMd5ByBytes([]byte("hello"))
s, err := cryptox.GetFileMd5("D:/tmp/a.zip") // 读整个文件后计算
```
完整可运行例程:[examples/cryptox/main.go](../examples/cryptox/main.go)
## 注意
- MD5 仅用于非安全场景的校验/去重,不用于密码存储或签名。
- `GetFileMd5` 为一次性 `os.ReadFile` 全量读入,超大文件注意内存占用。