core

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2022 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PEM_BEGIN = "-----BEGIN RSA PRIVATE KEY-----\n"
	PEM_END   = "\n-----END RSA PRIVATE KEY-----"
)

Variables

View Source
var (
	ShangHaiTimeLocation, _ = time.LoadLocation("Asia/Shanghai")
)

Functions

func DecodeWithError

func DecodeWithError(responseBytes []byte, obj interface{}, apiName string) error

func FormatPrivateKey

func FormatPrivateKey(privateKey string) string

func GetJson

func GetJson(ctx *Context, uri string, obj interface{}) ([]byte, error)

func NewConfig

func NewConfig()

func PKCS5Padding

func PKCS5Padding(ciphertext []byte, blockSize int) []byte

func PKCS5UnPadding

func PKCS5UnPadding(origData []byte) []byte

func ParsePrivateKey

func ParsePrivateKey(privateKey string) (priKey *rsa.PrivateKey, err error)

func PostForm

func PostForm(ctx *Context, uri, apiName string, obj interface{}, files map[string]io.Reader) ([]byte, error)

func PostJSON

func PostJSON(ctx *Context, uri string, obj interface{}) ([]byte, error)

func RsaSign

func RsaSign(plaintext string, privateKey string) (ciphertext string, err error)

func TripleDesDecrypt

func TripleDesDecrypt(crypted, des3key []byte) ([]byte, error)

3DES解密

func TripleDesEncrypt

func TripleDesEncrypt(origData, des3key []byte) ([]byte, error)

3DES加密

Types

type CommonResponse

type CommonResponse struct {
	Code      StatusCode `json:"code"`
	Message   string     `json:"message"`
	RequestId string     `json:"request_id"`
}

type Config

type Config struct {
	DesKey     string `json:"des_key" yaml:"des_key" mapstructure:"des_key"`
	Appkey     string `json:"app_key" yaml:"app_key" mapstructure:"app_key"`
	Dealer     string `json:"dealer" yaml:"dealer" mapstructure:"dealer"`
	Broker     string `json:"broker" yaml:"broker" mapstructure:"broker"`
	PrivateKey string `json:"private_key" yaml:"private_key" mapstructure:"private"`
}

Config for 云账户

type Context

type Context struct {
	*Config

	ApiAddr string
	Signer  Signer
	// contains filtered or unexported fields
}

func NewContext

func NewContext(ctx context.Context, cnf *Config, apiAddr string, sign Signer) *Context

func (*Context) Deadline

func (ctx *Context) Deadline() (deadline time.Time, ok bool)

func (*Context) Done

func (ctx *Context) Done() <-chan struct{}

func (*Context) Err

func (ctx *Context) Err() error

func (*Context) Value

func (ctx *Context) Value(key interface{}) interface{}

type Error

type Error struct {
	Code      StatusCode
	Message   string
	RequestId string
	ApiName   string
}

func (*Error) Error

func (e *Error) Error() string

type Signer

type Signer interface {
	Type() string
	Sign(params string) (string, error)
}

func NewRsaSing

func NewRsaSing(privateKey string) Signer

func NewSHA256Sign

func NewSHA256Sign(key string) Signer

type StatusCode

type StatusCode string

func (StatusCode) Message

func (s StatusCode) Message() string

type Time

type Time struct{ time.Time }

func (Time) MarshalJSON

func (t Time) MarshalJSON() ([]byte, error)

func (*Time) UnmarshalJson

func (t *Time) UnmarshalJson(data []byte) (err error)

Jump to

Keyboard shortcuts

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