support

package
v2.0.1-beta18 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2022 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorBase64Decode  = -40010 // base64 解码失败
	ErrorEncryptAes    = -40006 // AES 加密失败
	ErrorDecryptAes    = -40007 // AES 解密失败
	ErrorInvalidAesKey = -40004 // AESKey 非法
	ErrorInvalidIv     = -10001 // AESKey 非法
)
View Source
const (
	SignatureMessageFormat = "%s\n%s\n%s\n%s\n%s\n" // 数字签名原文格式

	// HeaderAuthorizationFormat 请求头中的 Authorization 拼接格式
	HeaderAuthorizationFormat = "%s mchid=\"%s\",nonce_str=\"%s\",timestamp=\"%d\",serial_no=\"%s\",signature=\"%s\""
)

请求报文签名相关常量

Variables

This section is empty.

Functions

func DecryptAES256GCM

func DecryptAES256GCM(aesKey, associatedData, nonce, ciphertext string) (plaintext string, err error)

DecryptAES256GCM 使用 AEAD_AES_256_GCM 算法进行解密

你可以使用此算法完成微信支付平台证书和回调报文解密,详见: https://wechatpay-api.gitbook.io/wechatpay-api-v3/qian-ming-zhi-nan-1/zheng-shu-he-hui-tiao-bao-wen-jie-mi

func GenerateSignHmacSHA256

func GenerateSignHmacSHA256(params *power.StringMap, key string) string

GenerateSignHmacSHA256 适用于微信支付V2 HMAC-SHA256签名算法 https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=4_3

func GenerateSignMD5

func GenerateSignMD5(params *power.StringMap, key string) string

GenerateSignMD5 适用于微信支付V2 MD5签名算法 https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=4_3

func PaymentV2ParamsJoin

func PaymentV2ParamsJoin(params *power.StringMap, key string) string

func PaymentV2ParamsJoinBackup

func PaymentV2ParamsJoinBackup(params *power.HashMap, key string) string

func SignSHA256WithRSA

func SignSHA256WithRSA(source string, privateKey *rsa.PrivateKey) (signature string, err error)

SignSHA256WithRSA 通过私钥对字符串以 SHA256WithRSA 算法生成签名信息

Types

type AES

type AES struct{}

func NewAES

func NewAES() *AES

func (AES) Decrypt

func (a AES) Decrypt(cipherText string, key, iv []byte) ([]byte, *CryptError)

Decrypt AES解密 cipherText 是密文的base64字符串 key和iv是经过反base64之后的byte内容 例如:原始值是"tiihtNczf5v6AKRyjwEUhQ==",那么应该用base64.StdEncoding.DecodeString("tiihtNczf5v6AKRyjwEUhQ==")解码之后传过来

func (AES) Encrypt

func (a AES) Encrypt(text []byte, key, iv []byte) ([]byte, *CryptError)

func (*AES) PKCS7Padding

func (a *AES) PKCS7Padding(text []byte, blockSize int) []byte

PKCS7Padding PKCS#7 padding.

func (*AES) PKCS7UnPadding

func (a *AES) PKCS7UnPadding(text []byte) ([]byte, *CryptError)

PKCS7UnPadding KCS#7 unPadding.

type CryptError

type CryptError struct {
	ErrCode int
	ErrMsg  string
}

func NewCryptError

func NewCryptError(errCode int, errMsg string) *CryptError

type Observable

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

func NewObservable

func NewObservable() *Observable

func (*Observable) Dispatch

func (observable *Observable) Dispatch(request *http.Request, event int, header contract.EventInterface, content interface{}) interface{}

func (*Observable) Observe

func (observable *Observable) Observe(condition int, handler contract.EventHandlerInterface) *Observable

func (*Observable) On

func (observable *Observable) On(condition int, handler contract.EventHandlerInterface) *Observable

func (*Observable) Push

func (observable *Observable) Push(closure contract.EventHandlerInterface, condition int) *Observable

func (*Observable) PushMessage

func (observable *Observable) PushMessage(closure contract.EventHandlerInterface, condition int) *Observable

func (*Observable) SetHandlers

func (observable *Observable) SetHandlers(handlers [][]*contract.EventHandlerInterface) *Observable

type RSAOaep

type RSAOaep struct {
	PublicKeyPath  string // RSA公钥路径,会自动读取出*rsa.PrivateKey
	PublicKey      *rsa.PublicKey
	PrivateKeyPath string
	PrivateKey     *rsa.PrivateKey
}

func (*RSAOaep) DecryptOAEP

func (r *RSAOaep) DecryptOAEP(hash hash.Hash, cipherMsg []byte) ([]byte, error)

func (*RSAOaep) EncryptOAEP

func (r *RSAOaep) EncryptOAEP(text []byte) ([]byte, error)

type RequestSignChain

type RequestSignChain struct {
	Method       string // 接口提交方法。"GET", "POST"等
	CanonicalURL string // 微信支付接口路径。 例如: /v3/pay/transactions/jsapi
	SignBody     string // 提交的body字符串。 例如; {"amount":{"total":1},"appid":"ww16143ea0101327c7","attach":"自定义数据说明","description":"Image形象店-深圳腾大-QQ公仔","mchid":"1611854986","notify_url":"https://pay.wangchaoyi.com/wx/notify","out_trade_no":"5519778939773395659222199361","payer":{"openid":"oAuaP0TRUMwP169nQfg7XCEAw3HQ"}}
	// contains filtered or unexported fields
}

type ResponseCastable

type ResponseCastable struct {
}

func (*ResponseCastable) CastResponseToType

func (responseCastable *ResponseCastable) CastResponseToType(response *http.Response, castType string) (interface{}, error)

func (*ResponseCastable) DetectAndCastResponseToType

func (responseCastable *ResponseCastable) DetectAndCastResponseToType(response interface{}, toType string) (interface{}, error)

type SHA256WithRSASigner

type SHA256WithRSASigner struct {
	MchID               string          // 商户号
	CertificateSerialNo string          // 商户证书序列号
	PrivateKeyPath      string          // 商户私钥路径,会自动读取出*rsa.PrivateKey
	PrivateKey          *rsa.PrivateKey // 商户私钥
}

SHA256WithRSASigner Sha256WithRSA 数字签名生成器

func (*SHA256WithRSASigner) Algorithm

func (s *SHA256WithRSASigner) Algorithm() string

Algorithm 返回使用的签名算法:SHA256-RSA2048

func (*SHA256WithRSASigner) GenerateRequestSign

func (s *SHA256WithRSASigner) GenerateRequestSign(signChain *RequestSignChain) (authorization string, err error)

func (*SHA256WithRSASigner) GenerateSign

func (s *SHA256WithRSASigner) GenerateSign(message string) (sign string, err error)

func (*SHA256WithRSASigner) GetAuthorizationType

func (s *SHA256WithRSASigner) GetAuthorizationType() string

func (*SHA256WithRSASigner) Sign

Sign 对信息使用 SHA256WithRSA 算法进行签名

type SignatureResult

type SignatureResult struct {
	MchID               string // 商户号
	CertificateSerialNo string // 签名对应的证书序列号
	Signature           string // 签名内容
}

SignatureResult 数字签名结果

Jump to

Keyboard shortcuts

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