1 Star 0 Fork 0

曾广宇/mxx-core-v2

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
util.go 563 Bytes
一键复制 编辑 原始数据 按行查看 历史
曾广宇 提交于 2024-07-11 11:16 +08:00 . 修正删除代码
package mutil
import (
"crypto/md5"
"crypto/sha256"
"encoding/hex"
"hash/fnv"
)
func Hash(data string) (uint32, error) {
h := fnv.New32a()
if _, err := h.Write([]byte(data)); err == nil {
return h.Sum32(), nil
} else {
return 0, err
}
}
func Md5(data string) string {
hasher := md5.New()
hasher.Write([]byte(data))
hashBytes := hasher.Sum(nil)
return hex.EncodeToString(hashBytes)
}
func Sha256Hash(data string) string {
hasher := sha256.New()
hasher.Write([]byte(data))
hashBytes := hasher.Sum(nil)
return hex.EncodeToString(hashBytes)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/dennis-mxx/mxx-core-v2.git
git@gitee.com:dennis-mxx/mxx-core-v2.git
dennis-mxx
mxx-core-v2
mxx-core-v2
v0.4.74

搜索帮助