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) (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
SignedValidTime signed TTL verify
Types ¶
type APISign ¶
type APISign struct {
// contains filtered or unexported fields
}
APISign API Param Sign
- rawStr eg: GET http://example.com/hello?n=1&a=2 Key["n","a"]-ASC Sort["a","n"] GetParam(a) a=2&n=1 param key string attaches the methods
- other request http method,for Content-Type: application/json {"n":"m","a":2} Key ASC Sort,param key string attaches the methods => {"a":2,"n":"m"} => a=2&n=m
- rawStr+timestamp => a=2&n=m1626167650 (1626167650 is unix timestamp), verify sign time valid(default 10s)
- Sign Method: Method(rawStr+timestamp, secretKey) signed text encode [Base64, Hex(default)] Method=[HMAC-SHA256,HMAC-SHA1] Encode=[Base64,Hex] Default = HMAC-SHA256-HEX
- default: signStr=Hex(HMAC-SHA256(rawStr+timestamp,secretKey))
- Sign http request Header X-Signature=accessKey:signStr:timestamp (: split elem)
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)
SortToString request body param sort format
func (RequestBodyMap) TrimNewline ¶
func (r RequestBodyMap) TrimNewline(buf []byte) []byte
Click to show internal directories.
Click to hide internal directories.