Documentation
¶
Index ¶
- Constants
- func Hmac5Sign(secretKey, body string) []byte
- func Md5Sign(_, body string) []byte
- func RandString(num int) string
- func SetKeyNameAppId(name string)
- func SetKeyNameNonceStr(name string)
- func SetKeyNameSign(name string)
- func SetKeyNameTimestamp(name string)
- func SortKVPairs(m url.Values) string
- type CryptoFunc
- type DefaultKeyName
- type GoSigner
- func (slf *GoSigner) AddBodies(key string, value []string) *GoSigner
- func (slf *GoSigner) AddBody(key string, value string) *GoSigner
- func (slf *GoSigner) GetAppId() string
- func (slf *GoSigner) GetBody() url.Values
- func (slf *GoSigner) GetNonceStr() string
- func (slf *GoSigner) GetSignBodyString() string
- func (slf *GoSigner) GetSignature() string
- func (slf *GoSigner) GetSignedQuery() string
- func (slf *GoSigner) GetTimeStamp() string
- func (slf *GoSigner) MakeRawBodyString() string
- func (slf *GoSigner) MakeSign() string
- func (slf *GoSigner) MakeSignedQuery() string
- func (slf *GoSigner) RandNonceStr() *GoSigner
- func (slf *GoSigner) SetAppId(appId string) *GoSigner
- func (slf *GoSigner) SetAppSecret(appSecret string) *GoSigner
- func (slf *GoSigner) SetAppSecretWrapBody(appSecret string) *GoSigner
- func (slf *GoSigner) SetBody(body url.Values)
- func (slf *GoSigner) SetNonceStr(nonce string) *GoSigner
- func (slf *GoSigner) SetSignBodyPrefix(prefix string) *GoSigner
- func (slf *GoSigner) SetSignBodySuffix(suffix string) *GoSigner
- func (slf *GoSigner) SetSplitChar(split string) *GoSigner
- func (slf *GoSigner) SetTimeStamp(ts int64) *GoSigner
- type GoVerifier
- func (slf *GoVerifier) CheckTimeStamp() error
- func (slf *GoVerifier) GetAppId() string
- func (slf *GoVerifier) GetBody() url.Values
- func (slf *GoVerifier) GetBodyWithoutSign() url.Values
- func (slf *GoVerifier) GetNonceStr() string
- func (slf *GoVerifier) GetSign() string
- func (slf *GoVerifier) GetTimestamp() int64
- func (slf *GoVerifier) MustHasKeys(keys ...string) error
- func (slf *GoVerifier) MustHasOtherKeys(keys ...string) error
- func (slf *GoVerifier) MustInt64(key string) int64
- func (slf *GoVerifier) MustString(key string) string
- func (slf *GoVerifier) MustStrings(key string) []string
- func (slf *GoVerifier) ParseQuery(requestUri string) error
- func (slf *GoVerifier) ParseValues(values url.Values)
- func (slf *GoVerifier) SetTimeout(timeout time.Duration) *GoVerifier
Constants ¶
View Source
const ( KeyNameTimestamp = "timestamp" KeyNameNonceStr = "nonce" KeyNameAppId = "appid" KeyNameSign = "sign" )
Variables ¶
This section is empty.
Functions ¶
func SetKeyNameAppId ¶
func SetKeyNameAppId(name string)
func SetKeyNameNonceStr ¶
func SetKeyNameNonceStr(name string)
func SetKeyNameSign ¶
func SetKeyNameSign(name string)
func SetKeyNameTimestamp ¶
func SetKeyNameTimestamp(name string)
Types ¶
type DefaultKeyName ¶
type DefaultKeyName struct {
// contains filtered or unexported fields
}
func (*DefaultKeyName) SetKeyNameAppId ¶
func (slf *DefaultKeyName) SetKeyNameAppId(name string)
func (*DefaultKeyName) SetKeyNameNonceStr ¶
func (slf *DefaultKeyName) SetKeyNameNonceStr(name string)
func (*DefaultKeyName) SetKeyNameSign ¶
func (slf *DefaultKeyName) SetKeyNameSign(name string)
func (*DefaultKeyName) SetKeyNameTimestamp ¶
func (slf *DefaultKeyName) SetKeyNameTimestamp(name string)
type GoSigner ¶
type GoSigner struct { *DefaultKeyName // contains filtered or unexported fields }
func NewGoSigner ¶
func NewGoSigner(cryptoFunc CryptoFunc) *GoSigner
func NewGoSignerHmac ¶
func NewGoSignerHmac() *GoSigner
func NewGoSignerMd5 ¶
func NewGoSignerMd5() *GoSigner
func (*GoSigner) GetSignBodyString ¶
GetSignBodyString 获取用于签名的原始字符串
func (*GoSigner) GetSignedQuery ¶
GetSignedQuery 获取带签名参数的字符串
func (*GoSigner) MakeRawBodyString ¶
MakeRawBodyString 获取用于签名的原始字符串
func (*GoSigner) MakeSignedQuery ¶
GetSignedQuery 获取带签名参数的字符串
func (*GoSigner) RandNonceStr ¶
RandNonceStr 自动生成16位随机字符串参数
func (*GoSigner) SetAppSecret ¶
SetAppSecret 设置签名密钥
func (*GoSigner) SetAppSecretWrapBody ¶
SetAppSecretWrapBody 在签名参数体的首部和尾部,拼接AppSecret字符串。
func (*GoSigner) SetNonceStr ¶
SetNonceStr 设置随机字符串参数
func (*GoSigner) SetSignBodyPrefix ¶
SetSignBodyPrefix 设置签名字符串的前缀字符串
func (*GoSigner) SetSignBodySuffix ¶
SetSignBodySuffix 设置签名字符串的后缀字符串
func (*GoSigner) SetSplitChar ¶
SetSplitChar设置前缀、后缀与签名体之间的分隔符号。默认为空字符串
func (*GoSigner) SetTimeStamp ¶
SetTimeStamp 设置时间戳参数
type GoVerifier ¶
type GoVerifier struct { *DefaultKeyName // contains filtered or unexported fields }
func NewGoVerifier ¶
func NewGoVerifier() *GoVerifier
func (*GoVerifier) GetAppId ¶
func (slf *GoVerifier) GetAppId() string
func (*GoVerifier) GetBody ¶
func (slf *GoVerifier) GetBody() url.Values
func (*GoVerifier) GetBodyWithoutSign ¶
func (slf *GoVerifier) GetBodyWithoutSign() url.Values
GetBodyWithoutSign 获取所有参数体。其中不包含sign 字段
func (*GoVerifier) GetNonceStr ¶
func (slf *GoVerifier) GetNonceStr() string
func (*GoVerifier) GetSign ¶
func (slf *GoVerifier) GetSign() string
func (*GoVerifier) GetTimestamp ¶
func (slf *GoVerifier) GetTimestamp() int64
func (*GoVerifier) MustHasKeys ¶
func (slf *GoVerifier) MustHasKeys(keys ...string) error
MustHasKeys 必须包含指定的字段参数
func (*GoVerifier) MustHasOtherKeys ¶
func (slf *GoVerifier) MustHasOtherKeys(keys ...string) error
MustHasKeys 必须包含除特定的[timestamp, nonce, sign, appid]等之外的指定的字段参数
func (*GoVerifier) MustInt64 ¶
func (slf *GoVerifier) MustInt64(key string) int64
MustInt64 获取Int64值
func (*GoVerifier) MustString ¶
func (slf *GoVerifier) MustString(key string) string
MustString 获取字符串值
func (*GoVerifier) MustStrings ¶
func (slf *GoVerifier) MustStrings(key string) []string
MustString 获取字符串值数组
func (*GoVerifier) ParseQuery ¶
func (slf *GoVerifier) ParseQuery(requestUri string) error
ParseQuery 将参数字符串解析成参数列表
func (*GoVerifier) ParseValues ¶
func (slf *GoVerifier) ParseValues(values url.Values)
ParseValues 将Values参数列表解析成参数Map。如果参数是多值的,则将它们以逗号Join成字符串。
func (*GoVerifier) SetTimeout ¶
func (slf *GoVerifier) SetTimeout(timeout time.Duration) *GoVerifier
SetTimeout 设置签名校验过期时间
Click to show internal directories.
Click to hide internal directories.