mirror of
https://github.com/silenceper/wechat.git
synced 2026-02-04 12:52:27 +08:00
Co-authored-by: Avtion <manaitao@heywoods.cn>
This commit is contained in:
@@ -198,10 +198,10 @@ func decodeNetworkByteOrder(orderBytes []byte) (n uint32) {
|
|||||||
// CalculateSign 计算签名
|
// CalculateSign 计算签名
|
||||||
func CalculateSign(content, signType, key string) (string, error) {
|
func CalculateSign(content, signType, key string) (string, error) {
|
||||||
var h hash.Hash
|
var h hash.Hash
|
||||||
if signType == SignTypeMD5 {
|
if signType == SignTypeHMACSHA256 {
|
||||||
h = md5.New()
|
|
||||||
} else {
|
|
||||||
h = hmac.New(sha256.New, []byte(key))
|
h = hmac.New(sha256.New, []byte(key))
|
||||||
|
} else {
|
||||||
|
h = md5.New()
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := h.Write([]byte(content)); err != nil {
|
if _, err := h.Write([]byte(content)); err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user