core

package
v0.0.0-...-f535f45 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBadPem = errors.New("decode pem failed")
View Source
var (
	// ErrorInvalidSign 签名校验失败
	ErrorInvalidSign = errors.New("invalid signature")
)

Functions

func BuildSignatureString

func BuildSignatureString(fieldMap map[string]interface{}) string

构建需要签名的字符串

func CheckSign

func CheckSign(originalData, signData string, publicKey []byte) error

CheckSign 验签:对采用sha1算法进行签名后转base64格式的数据进行验签

func Sign

func Sign(v SignatureStruct, rsaPrivateKey []byte) (string, error)

Sign 签名

1 用私钥对明文进行加密
2 对密文进行sha1摘要

https://dianshang.baidu.com/platform/doclist/index.html#!/doc/nuomiplus_2_base/anchor/sign.md

func SimpleRequest

func SimpleRequest(client *http.Client, url string, method string, header map[string]string, body []byte) (*http.Response, error)

Types

type ApiUrl

type ApiUrl string
const (
	SyncOrderStatusUrl  ApiUrl = "https://etrade-api.baidu.com/cashier/syncOrderStatus"
	ApplyOrderRefundUrl ApiUrl = "https://etrade-api.baidu.com/cashier/applyOrderRefund"
)

func (ApiUrl) String

func (c ApiUrl) String() string

type ResponseErr

type ResponseErr struct {
	ErrNo int32
	Msg   string
}

func (*ResponseErr) Error

func (e *ResponseErr) Error() string

type SignFieldsRangeType

type SignFieldsRangeType int

SignFieldsRangeType 用于区分验签字段范围,signFieldsRange 的值:

const (
	SignFieldsRangeTypeBasic  SignFieldsRangeType = 0 // 0:原验签字段 appKey+dealId+tpOrderId;
	SignFieldsRangeTypeAmount SignFieldsRangeType = 1 //  1:包含 totalAmount 的验签,验签字段包括 appKey+dealId+tpOrderId+totalAmount,固定值为 1
)

type SignatureStruct

type SignatureStruct interface {
	FieldMap() map[string]interface{}
	FieldForm() url.Values
}

Jump to

Keyboard shortcuts

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