signature

package
v0.1.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 18, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// 签名公共字段:
	SignPublicKeyName  = "public_key"  // 字段名: 公钥
	SignPrivateKeyName = "private_key" // 字段名: 私钥
	SignNonceName      = "nonce"       // 字段名: 随机串
	SignTimestampName  = "ts"          // 字段名: 时间戳
	SignTypeName       = "sign_type"   // 字段名: 签名算法类型
	SignResultName     = "sign"        // 字段名: 签名结果

	// 签名算法类型:
	SignMD5    = "md5"    // md5
	SignSHA256 = "sha256" // sha256
	SignSHA512 = "sha512" // sha512
)

Variables

This section is empty.

Functions

This section is empty.

Types

type PrivateKeyFunc

type PrivateKeyFunc func(publicKey string) (privateKey string, err error)

get appSecret/privateKey by appKey/publicKey

type Signer

type Signer struct {
	// contains filtered or unexported fields
}

func New

func New(publicKeyName string, nonceName string, timestampName string) *Signer

func (*Signer) SignMD5

func (m *Signer) SignMD5(payload url.Values, publicKey string, nonce string, timestamp string, toLower bool, keyFn PrivateKeyFunc) (sign string)

签名生成:

func (*Signer) VerifyMD5

func (m *Signer) VerifyMD5(data url.Values, toLower bool, keyFn PrivateKeyFunc) bool

签名验证:

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL