1 Star 0 Fork 97

Ostaer / 微信Go SDK

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
sign_with_type.go 999 Bytes
一键复制 编辑 原始数据 按行查看 历史
shallot 提交于 2020-04-23 04:27 . 更新为Apache 2.0开源许可证。
/*
Copyright 2020 XiaochengTech
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package util
import (
"encoding/hex"
"gitee.com/xiaochengtech/wechat/constant"
"strings"
)
// 根据签名类型,生成签名
func SignWithType(signType string, origin string, apiKey string) string {
var hashSign []byte
if signType == constant.SignTypeHmacSHA256 {
hashSign = HmacSha256(origin, apiKey)
} else {
hashSign = Md5(origin)
}
return strings.ToUpper(hex.EncodeToString(hashSign))
}
Go
1
https://gitee.com/ostaer/wechat.git
git@gitee.com:ostaer/wechat.git
ostaer
wechat
微信Go SDK
0316726b8f2f

搜索帮助