代码拉取完成,页面将自动刷新
package com
/**
* @Author : xingnan
* @Email : 457415936@qq.com
* @Time : 15:35
* @File : hash.go
* @Project : toolbox
* @Description : GoLand
*/
import (
"crypto/hmac"
"crypto/md5"
"crypto/sha1"
"crypto/sha256"
"encoding/hex"
"fmt"
)
func Md5(value string) string {
h := md5.New()
h.Write([]byte(value))
return fmt.Sprintf("%s", hex.EncodeToString(h.Sum(nil)))
}
func Hmac(key, data string) string {
h := hmac.New(md5.New, []byte(key))
h.Write([]byte(data))
return hex.EncodeToString(h.Sum([]byte("")))
}
func HmacSha256(secret string, data string) string {
h := hmac.New(sha256.New, []byte(secret))
h.Write([]byte(data))
return hex.EncodeToString(h.Sum(nil))
}
//sha1加密
func Sha1(s string) string {
h := sha1.New()
h.Write([]byte(s))
rs := hex.EncodeToString(h.Sum(nil))
return rs
}
func ToSha1(s string) string {
h := sha1.New()
h.Write([]byte(s))
rs := hex.EncodeToString(h.Sum(nil))
return rs
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。