1 Star 0 Fork 2

niniwowo / go-qq-openapi-v3

forked from Rex / go-qq-openapi-v3 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
sns_sig.go 740 Bytes
一键复制 编辑 原始数据 按行查看 历史
Rex 提交于 2013-11-09 22:44 . update test for pay_helper
//
//
//
package qqopenapi_v3
import (
"fmt"
"log"
"crypto/hmac"
"crypto/sha1"
"encoding/base64"
"net/url"
"strings"
)
func mk_source(method, url_path string, params url.Values) string {
return fmt.Sprintf("%s&%s&%s",
strings.ToUpper(method),
url.QueryEscape(url_path),
url_encode(params, false))
}
func hmac_sha1_sig(method, url_path, secret string, params url.Values) string {
var source = mk_source(method, url_path, params)
var hashed = hmac.New(sha1.New, []byte(secret))
n, err := hashed.Write([]byte(source))
if n != len(source) || err != nil {
log.Println("Hmac write error!", err)
return ""
}
return base64.StdEncoding.EncodeToString(hashed.Sum(nil))
}
Go
1
https://gitee.com/niniwowo99/go-qq-openapi-v3.git
git@gitee.com:niniwowo99/go-qq-openapi-v3.git
niniwowo99
go-qq-openapi-v3
go-qq-openapi-v3
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891