1 Star 0 Fork 63

南风不竞/dongle

forked from dromara/dongle 
加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
hmac_sha1.go 428 Bytes
一键复制 编辑 原始数据 按行查看 历史
kuafuRace 提交于 2022-05-21 13:22 +08:00 . v0.1.0 更新注释信息
package dongle
import (
"crypto/hmac"
"crypto/sha1"
"hash"
)
// ByHmacSha1 encrypts by hmac with sha1.
// 通过 hmac-sha1 加密
func (e encrypt) ByHmacSha1(key interface{}) encrypt {
if len(e.src) == 0 {
return e
}
var mac hash.Hash
switch v := key.(type) {
case string:
mac = hmac.New(sha1.New, string2bytes(v))
case []byte:
mac = hmac.New(sha1.New, v)
}
mac.Write(e.src)
e.dst = mac.Sum(nil)
return e
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/limengcanyu/dongle.git
git@gitee.com:limengcanyu/dongle.git
limengcanyu
dongle
dongle
master

搜索帮助