2 Star 0 Fork 0

TeamsHub/backend-gopkg

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
signature.go 953 Bytes
一键复制 编辑 原始数据 按行查看 历史
HCY 提交于 2024-05-10 12:41 +08:00 . c
package signature
import (
"net/http"
"net/url"
"time"
)
var _ Signature = (*signature)(nil)
const (
delimiter = "|"
)
// 合法的 Methods
var methods = map[string]bool{
http.MethodGet: true,
http.MethodPost: true,
http.MethodHead: true,
http.MethodPut: true,
http.MethodPatch: true,
http.MethodDelete: true,
http.MethodConnect: true,
http.MethodOptions: true,
http.MethodTrace: true,
}
type Signature interface {
i()
// Generate 生成签名
Generate(path string, method string, params url.Values) (authorization, date string, err error)
// Verify 验证签名
Verify(authorization, date string, path string, method string, params url.Values) (ok bool, err error)
}
type signature struct {
key string
secret string
ttl time.Duration
}
func New(key, secret string, ttl time.Duration) Signature {
return &signature{
key: key,
secret: secret,
ttl: ttl,
}
}
func (s *signature) i() {}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wuzheng0709/backend-gopkg.git
git@gitee.com:wuzheng0709/backend-gopkg.git
wuzheng0709
backend-gopkg
backend-gopkg
v1.6.5

搜索帮助