Documentation
¶
Index ¶
- func HmacHash(method Method, rawStr, secretKey string) string
- func HmacSha1ToBase64(rawStr, key string) string
- func HmacSha1ToHex(rawStr, key string) string
- func HmacSha256ToBase64(rawStr, key string) string
- func HmacSha256ToHex(rawStr, key string) string
- func SortParamForm(req *http.Request, path bool) (string, error)
- type APISign
- type Kv
- type KvSlice
- type Method
- type RequestBodyMap
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HmacSha1ToBase64 ¶
HmacSha1ToBase64 HMAC-SHA1 签名并BASE64 编码
func HmacSha256ToBase64 ¶
HmacSha256ToBase64 HMAC-SHA256 签名并BASE64 编码
Types ¶
type APISign ¶
type APISign struct {
// contains filtered or unexported fields
}
1. 签名头X-Signature=accessKey:signStr:timestamp (:分割不同元素) 2. 签名方式: Method(rawStr+timestamp, secretKey) 最终signStr是Base64编码 3. rawStr 解释 如果是 GET请求,例子: http://example.com/hello?n=1&a=2 => /hello?a=2&n=11626167650 参数要进行字符正序 4. 非GET请求,对于Content-Type: application/json {"n":"m","a":2} 也进行字符正序 => {"a":2,"n":"m"} 最终 a=2&n=m 5. rawStr+timestamp = /hello?a=2&n=m1626167650 时间戳(秒) 最终在签名,携带时间戳,是为了验证签名时间有效性 当前有效性 -+10s 6. 最终形式都是 path?/k=v&k1=v1 + timestamp
APISign 接口签名
func NewAPISign ¶
signValidDuration sign valid time interval
func (*APISign) SetGetSecretKey ¶
SetGetSecretKey 设置SecretKey 获取方法
type RequestBodyMap ¶
type RequestBodyMap map[string]interface{}
func (RequestBodyMap) GetStringValue ¶
func (r RequestBodyMap) GetStringValue(key string) (string, error)
func (RequestBodyMap) SortToString ¶
func (r RequestBodyMap) SortToString(separator string) (string, error)
func (RequestBodyMap) TrimNewline ¶
func (r RequestBodyMap) TrimNewline(buf []byte) []byte
Click to show internal directories.
Click to hide internal directories.