1 Star 4 Fork 0

火火/golang-common

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
encryption.go 477 Bytes
一键复制 编辑 原始数据 按行查看 历史
火火 提交于 2020-04-02 00:04 +08:00 . 11
package utils
import (
"crypto/md5"
"crypto/sha1"
"crypto/sha256"
"encoding/hex"
"fmt"
)
func GetMd5Value(data string) string {
md5Ctx := md5.New()
md5Ctx.Write([]byte(data))
return hex.EncodeToString(md5Ctx.Sum(nil))
}
func GetSha256Value(data string) string {
h := sha256.New()
h.Write([]byte(data))
return hex.EncodeToString(h.Sum(nil))
}
func GetSha1Value(data string) string {
h := sha1.New()
h.Write([]byte(data))
return fmt.Sprintf("%x", h.Sum(nil))
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/yxd1990/golang-common.git
git@gitee.com:yxd1990/golang-common.git
yxd1990
golang-common
golang-common
62252a89ea79

搜索帮助