Documentation ¶
Index ¶
- Constants
- func SignSHA256(payload DictType, publicKey string, nonce string, timestamp string, ...) string
- func VerifySHA256(data DictType, toLower bool, keyFn PrivateKeyFunc) bool
- func WithMD5(data string, privateKey string) string
- func WithSHA256(data string, privateKey string) string
- func WithSHA512(data string, privateKey string) string
- type DictType
- type PrivateKeyFunc
- type SignAlgorithmFunc
- type Signer
- func (m *Signer) Sign(payload DictType, publicKey string, nonce string, timestamp string, ...) (sign string)
- func (m *Signer) SignMD5(payload DictType, publicKey string, nonce string, timestamp string, ...) string
- func (m *Signer) SignSHA256(payload DictType, publicKey string, nonce string, timestamp string, ...) string
- func (m *Signer) SignSHA512(payload DictType, publicKey string, nonce string, timestamp string, ...) string
- func (m *Signer) Verify(data DictType, signType string, toLower bool, keyFn PrivateKeyFunc, ...) bool
- func (m *Signer) VerifyMD5(data DictType, toLower bool, keyFn PrivateKeyFunc) bool
- func (m *Signer) VerifySHA256(data DictType, toLower bool, keyFn PrivateKeyFunc) bool
- func (m *Signer) VerifySHA512(data DictType, toLower bool, keyFn PrivateKeyFunc) bool
Constants ¶
View Source
const ( // 签名公共字段: SignPublicKeyName = "public_key" // 字段名: 公钥 SignPrivateKeyName = "private_key" // 字段名: 私钥 SignNonceName = "nonce" // 字段名: 随机串 SignTimestampName = "ts" // 字段名: 时间戳 SignTypeName = "sign_type" // 字段名: 签名算法类型 SignResultName = "sign" // 字段名: 签名结果 // 签名算法类型: SignTypeMD5 = "md5" // md5 SignTypeSHA256 = "sha256" // sha256 SignTypeSHA512 = "sha512" // sha512 )
Variables ¶
This section is empty.
Functions ¶
func SignSHA256 ¶
func SignSHA256( payload DictType, publicKey string, nonce string, timestamp string, toLower bool, keyFn PrivateKeyFunc, ) string
use default field name:
func VerifySHA256 ¶ added in v0.1.13
func VerifySHA256( data DictType, toLower bool, keyFn PrivateKeyFunc, ) bool
use default field name:
func WithSHA256 ¶ added in v0.1.13
sha256 签名:
func WithSHA512 ¶ added in v0.1.13
sha512 签名:
Types ¶
type DictType ¶ added in v0.1.14
type DictType interface { Encode() string Get(key string) interface{} Set(key string, value interface{}) Del(key string) }
interface:
type PrivateKeyFunc ¶
get appSecret/privateKey by appKey/publicKey
type SignAlgorithmFunc ¶ added in v0.1.11
签名算法: useMD5/sha256/sha512
type Signer ¶
type Signer struct {
// contains filtered or unexported fields
}
func (*Signer) Sign ¶ added in v0.1.11
func (m *Signer) Sign( payload DictType, publicKey string, nonce string, timestamp string, signType string, toLower bool, keyFn PrivateKeyFunc, signFn SignAlgorithmFunc, ) (sign string)
签名生成:
func (*Signer) SignSHA256 ¶ added in v0.1.11
func (m *Signer) SignSHA256( payload DictType, publicKey string, nonce string, timestamp string, toLower bool, keyFn PrivateKeyFunc, ) string
sign with SHA256:
func (*Signer) SignSHA512 ¶ added in v0.1.11
func (m *Signer) SignSHA512(payload DictType, publicKey string, nonce string, timestamp string, toLower bool, keyFn PrivateKeyFunc, ) string
sign with SHA512:
func (*Signer) Verify ¶ added in v0.1.11
func (m *Signer) Verify( data DictType, signType string, toLower bool, keyFn PrivateKeyFunc, signFn SignAlgorithmFunc, ) bool
签名验证:
func (*Signer) VerifyMD5 ¶
func (m *Signer) VerifyMD5( data DictType, toLower bool, keyFn PrivateKeyFunc, ) bool
func (*Signer) VerifySHA256 ¶ added in v0.1.11
func (m *Signer) VerifySHA256( data DictType, toLower bool, keyFn PrivateKeyFunc, ) bool
func (*Signer) VerifySHA512 ¶ added in v0.1.11
func (m *Signer) VerifySHA512( data DictType, toLower bool, keyFn PrivateKeyFunc, ) bool
Click to show internal directories.
Click to hide internal directories.