Documentation ¶
Index ¶
- Constants
- func AesSign(secretKey, body string) []byte
- func Decrypt(decryptStr string, key []byte, iv string) (string, error)
- func Encrypt(encryptStr string, key []byte, iv string) (string, error)
- func HmacSign(secretKey, body string) []byte
- func Md5Sign(_, body string) []byte
- func PrivateDecrypt(decryptStr string, path string) (string, error)
- func PublicEncrypt(encryptStr string, path string) (string, error)
- func RsaSign(secretKey, body string) []byte
- func SortKVPairs(m url.Values) string
- type CryptoFunc
- type DefaultKeyName
- type Signer
- func (s *Signer) AddBodies(key string, value []string) *Signer
- func (s *Signer) AddBody(key string, value string) *Signer
- func (s *Signer) GetAppID() string
- func (s *Signer) GetBody() url.Values
- func (s *Signer) GetNonceStr() string
- func (s *Signer) GetSignBodyString() string
- func (s *Signer) GetSignature() string
- func (s *Signer) GetSignedQuery() string
- func (s *Signer) GetTimeStamp() string
- func (s *Signer) MakeRawBodyString() string
- func (s *Signer) MakeSign() string
- func (s *Signer) MakeSignedQuery() string
- func (s *Signer) RandNonceStr() *Signer
- func (s *Signer) SetAppID(appID string) *Signer
- func (s *Signer) SetAppSecret(appSecret string) *Signer
- func (s *Signer) SetAppSecretWrapBody(appSecret string) *Signer
- func (s *Signer) SetBody(body url.Values)
- func (s *Signer) SetNonceStr(nonce string) *Signer
- func (s *Signer) SetSignBodyPrefix(prefix string) *Signer
- func (s *Signer) SetSignBodySuffix(suffix string) *Signer
- func (s *Signer) SetSplitChar(split string) *Signer
- func (s *Signer) SetTimeStamp(ts int64) *Signer
- type Verifier
- func (v *Verifier) CheckTimeStamp() error
- func (v *Verifier) GetAppID() string
- func (v *Verifier) GetBody() url.Values
- func (v *Verifier) GetBodyWithoutSign() url.Values
- func (v *Verifier) GetNonceStr() string
- func (v *Verifier) GetSign() string
- func (v *Verifier) GetTimestamp() int64
- func (v *Verifier) MustHasKeys(keys ...string) error
- func (v *Verifier) MustHasOtherKeys(keys ...string) error
- func (v *Verifier) MustInt64(key string) int64
- func (v *Verifier) MustString(key string) string
- func (v *Verifier) MustStrings(key string) []string
- func (v *Verifier) ParseQuery(requestURI string) error
- func (v *Verifier) ParseValues(values url.Values)
- func (v *Verifier) SetTimeout(timeout time.Duration) *Verifier
Constants ¶
const ( // KeyNameTimeStamp 时间戳字段名 KeyNameTimeStamp = "timestamp" // KeyNameNonceStr temp str field KeyNameNonceStr = "nonce_str" // KeyNameAppID app id field KeyNameAppID = "app_id" // KeyNameSign sign field KeyNameSign = "sign" )
Variables ¶
This section is empty.
Functions ¶
func PrivateDecrypt ¶
PrivateDecrypt 私钥解密
func PublicEncrypt ¶
PublicEncrypt 公钥加密
Types ¶
type DefaultKeyName ¶
DefaultKeyName 签名需要用到的字段
func (*DefaultKeyName) SetKeyNameAppID ¶
func (d *DefaultKeyName) SetKeyNameAppID(name string)
SetKeyNameAppID 设定app id
func (*DefaultKeyName) SetKeyNameNonceStr ¶
func (d *DefaultKeyName) SetKeyNameNonceStr(name string)
SetKeyNameNonceStr 设定随机字符串
func (*DefaultKeyName) SetKeyNameSign ¶
func (d *DefaultKeyName) SetKeyNameSign(name string)
SetKeyNameSign 设定签名
func (*DefaultKeyName) SetKeyNameTimestamp ¶
func (d *DefaultKeyName) SetKeyNameTimestamp(name string)
SetKeyNameTimestamp 设定时间戳
type Signer ¶
type Signer struct { *DefaultKeyName // contains filtered or unexported fields }
Signer define
func (*Signer) GetSignBodyString ¶
GetSignBodyString 获取用于签名的原始字符串
func (*Signer) GetSignedQuery ¶
GetSignedQuery 获取带签名参数的查询字符串
func (*Signer) MakeRawBodyString ¶
MakeRawBodyString 获取用于签名的原始字符串
func (*Signer) MakeSignedQuery ¶
MakeSignedQuery 获取带签名参数的字符串
func (*Signer) SetAppSecret ¶
SetAppSecret 设置签名密钥
func (*Signer) SetAppSecretWrapBody ¶
SetAppSecretWrapBody 在签名参数体的首部和尾部,拼接AppSecret字符串。
func (*Signer) SetNonceStr ¶
SetNonceStr 设置随机字符串参数
func (*Signer) SetSignBodyPrefix ¶
SetSignBodyPrefix 设置签名字符串的前缀字符串
func (*Signer) SetSignBodySuffix ¶
SetSignBodySuffix 设置签名字符串的后缀字符串
func (*Signer) SetSplitChar ¶
SetSplitChar 设置前缀、后缀与签名体之间的分隔符号。默认为空字符串
type Verifier ¶
type Verifier struct { *DefaultKeyName // contains filtered or unexported fields }
Verifier define struct
func (*Verifier) GetBodyWithoutSign ¶
GetBodyWithoutSign 获取所有参数体。其中不包含sign 字段
func (*Verifier) MustHasKeys ¶
MustHasKeys 必须包含指定的字段参数
func (*Verifier) MustHasOtherKeys ¶
MustHasOtherKeys 必须包含除特定的[timestamp, nonce_str, sign, app_id]等之外的指定的字段参数
func (*Verifier) MustStrings ¶
MustStrings 获取字符串值数组
func (*Verifier) ParseQuery ¶
ParseQuery 将参数字符串解析成参数列表
func (*Verifier) ParseValues ¶
ParseValues 将Values参数列表解析成参数Map。如果参数是多值的,则将它们以逗号Join成字符串。