Documentation ¶
Index ¶
- func DecodeHeaderVal(headerVal string) (accessKey, signStr, timestamp string, err error)
- 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 SignedValidTime(t time.Time) error
- func SortParamForm(req *http.Request, path bool) (string, error)
- type APISign
- type Config
- type Kv
- type KvSlice
- type Method
- type RequestBodyMap
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeHeaderVal ¶ added in v0.1.3
DecodeHeaderVal header value decode to accessKey:signStr:timestamp
func HmacSha256ToBase64 ¶
HmacSha256ToBase64 HMAC-SHA256
func SignedValidTime ¶ added in v0.1.3
Types ¶
type APISign ¶
type APISign struct {
// contains filtered or unexported fields
}
1. Sign Header Key = X-Signature Value = accessKey:signStr:timestamp (: split elem) 2. Sign Method: Method(rawStr+timestamp, secretKey) signStr(rawStr+timestamp) => encoding Base64 | Hex(default) 3. rawStr eg: GET http://example.com/hello?n=1&a=2 => a=2&n=11626167650 param key string attaches the methods 4. other request http method,for Content-Type: application/json {"n":"m","a":2} param key string attaches the methods => {"a":2,"n":"m"} => a=2&n=m 5. rawStr+timestamp => a=2&n=m1626167650 timestamp(sec) verify sign time valid(default 10s) 6. if Config.PathSign = true URL.Path also need to sign, rawStr => /path?k=v&k1=v1 , default Config.PathSign = false
APISign API Sign
func (*APISign) SetGetSecretKey ¶
SetGetSecretKey setting SecretKey get function
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