Documentation
¶
Index ¶
- Constants
- Variables
- func DESDecryptECB(key, data []byte) ([]byte, error)
- func DESEncryptECB(key, data []byte) ([]byte, error)
- func HeaderEncode(h http.Header) string
- func LoadCertFromPfxFile(filename, password string) (tls.Certificate, error)
- func NewECBDecrypter(b cipher.Block) cipher.BlockMode
- func NewECBEncrypter(b cipher.Block) cipher.BlockMode
- type Client
- func (c *Client) Decrypt(cipher string) (string, error)
- func (c *Client) Encrypt(plain string) (string, error)
- func (c *Client) MchNO() string
- func (c *Client) MustEncrypt(plain string) string
- func (c *Client) PostForm(ctx context.Context, api, serviceNO string, bizData V) (gjson.Result, error)
- func (c *Client) VerifyNotify(form url.Values) (gjson.Result, error)
- type HTTPClient
- type HTTPOption
- type Option
- type PrivateKey
- type PublicKey
- type RSAPadding
- type ReqLog
- func (l *ReqLog) Do(ctx context.Context, log func(ctx context.Context, data map[string]string))
- func (l *ReqLog) Set(k, v string)
- func (l *ReqLog) SetReqBody(v string)
- func (l *ReqLog) SetReqHeader(h http.Header)
- func (l *ReqLog) SetRespBody(v string)
- func (l *ReqLog) SetRespHeader(h http.Header)
- func (l *ReqLog) SetStatusCode(code int)
- type V
- type VEmptyMode
- type VEncOption
Constants ¶
const ( SysOK = "SYS000" // 网关受理成功响应码 SysAccepting = "SYS001" // 网关受理中响应码 ComOK = "COM000" // 业务受理成功 ComProcessing = "COM004" // 业务处理中 )
Variables ¶
var ErrSysAccepting = errors.New("SYS001 | 网关受理中")
ErrSysAccepting 网关受理中
Functions ¶
func DESDecryptECB ¶ added in v1.0.3
DESDecryptECB DES-ECB 解密
func DESEncryptECB ¶ added in v1.0.3
DESEncryptECB DES-ECB 加密
func HeaderEncode ¶
func LoadCertFromPfxFile ¶
func LoadCertFromPfxFile(filename, password string) (tls.Certificate, error)
LoadCertFromPfxFile 通过pfx(p12)证书文件生成TLS证书 注意:证书需采用「TripleDES-SHA1」加密方式
func NewECBDecrypter ¶
NewECBDecrypter returns a BlockMode which decrypts in electronic code book mode, using the given Block.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client 银盛支付客户端
func (*Client) MustEncrypt ¶
MustEncrypt 敏感数据DES加密;若发生错误,则Panic
type HTTPClient ¶
type HTTPClient interface { // Do 发送HTTP请求 // 注意:应该使用Context设置请求超时时间 Do(ctx context.Context, method, reqURL string, body []byte, options ...HTTPOption) (*http.Response, error) }
HTTPClient HTTP客户端
func NewDefaultHTTPClient ¶
func NewDefaultHTTPClient() HTTPClient
NewDefaultHTTPClient 生成一个默认的HTTP客户端
func NewHTTPClient ¶
func NewHTTPClient(cli *http.Client) HTTPClient
NewHTTPClient 通过官方 `http.Client` 生成一个HTTP客户端
type HTTPOption ¶
type HTTPOption func(o *httpOptions)
HTTPOption HTTP请求选项
func WithHTTPCookies ¶
func WithHTTPCookies(cookies ...*http.Cookie) HTTPOption
WithHTTPCookies 设置HTTP请求Cookie
func WithHTTPHeader ¶
func WithHTTPHeader(key string, vals ...string) HTTPOption
WithHTTPHeader 设置HTTP请求头
type PrivateKey ¶
type PrivateKey struct {
// contains filtered or unexported fields
}
PrivateKey RSA私钥
func NewPrivateKeyFromPemBlock ¶
func NewPrivateKeyFromPemBlock(mode RSAPadding, pemBlock []byte) (*PrivateKey, error)
NewPrivateKeyFromPemBlock 通过PEM字节生成RSA私钥
func NewPrivateKeyFromPemFile ¶
func NewPrivateKeyFromPemFile(mode RSAPadding, pemFile string) (*PrivateKey, error)
NewPrivateKeyFromPemFile 通过PEM文件生成RSA私钥
func NewPrivateKeyFromPfxFile ¶
func NewPrivateKeyFromPfxFile(pfxFile, password string) (*PrivateKey, error)
NewPrivateKeyFromPfxFile 通过pfx(p12)证书生成RSA私钥 注意:证书需采用「TripleDES-SHA1」加密方式
func (*PrivateKey) Decrypt ¶
func (pk *PrivateKey) Decrypt(data []byte) ([]byte, error)
Decrypt RSA私钥 PKCS#1 v1.5 解密
func (*PrivateKey) DecryptOAEP ¶
DecryptOAEP RSA私钥 PKCS#1 OAEP 解密
type PublicKey ¶
type PublicKey struct {
// contains filtered or unexported fields
}
PublicKey RSA公钥
func NewPublicKeyFromDerBlock ¶
NewPublicKeyFromDerBlock 通过DER字节生成RSA公钥 注意PEM格式: -----BEGIN CERTIFICATE----- | -----END CERTIFICATE----- DER转换命令: openssl x509 -inform der -in cert.cer -out cert.pem
func NewPublicKeyFromDerFile ¶
NewPublicKeyFromDerFile 通过DER证书生成RSA公钥 注意PEM格式: -----BEGIN CERTIFICATE----- | -----END CERTIFICATE----- DER转换命令: openssl x509 -inform der -in cert.cer -out cert.pem
func NewPublicKeyFromPemBlock ¶
func NewPublicKeyFromPemBlock(mode RSAPadding, pemBlock []byte) (*PublicKey, error)
NewPublicKeyFromPemBlock 通过PEM字节生成RSA公钥
func NewPublicKeyFromPemFile ¶
func NewPublicKeyFromPemFile(mode RSAPadding, pemFile string) (*PublicKey, error)
NewPublicKeyFromPemFile 通过PEM文件生成RSA公钥
func (*PublicKey) EncryptOAEP ¶
EncryptOAEP RSA公钥 PKCS#1 OAEP 加密
type RSAPadding ¶ added in v1.0.2
type RSAPadding int
RSAPadding RSA PEM 填充模式
const ( RSA_PKCS1 RSAPadding = 1 // PKCS#1 (格式:`RSA PRIVATE KEY` 和 `RSA PUBLIC KEY`) RSA_PKCS8 RSAPadding = 8 // PKCS#8 (格式:`PRIVATE KEY` 和 `PUBLIC KEY`) )
type ReqLog ¶
type ReqLog struct {
// contains filtered or unexported fields
}
ReqLog 请求日志
type V ¶
V 用于处理 k-v 需要格式化的场景,如:签名
type VEmptyMode ¶ added in v1.0.4
type VEmptyMode int
VEmptyMode 值为空时的Encode模式
const ( EmptyDefault VEmptyMode = iota // 默认:bar=baz&foo= EmptyIgnore // 忽略:bar=baz EmptyOnlyKey // 仅保留Key:bar=baz&foo )
type VEncOption ¶
type VEncOption func(o *vEncOptions)
VEncOption V Encode 选项
func WithEmptyMode ¶ added in v1.0.4
func WithEmptyMode(mode VEmptyMode) VEncOption
WithEmptyMode 设置值为空时的Encode模式