util

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2019 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

加解密方法

公共方法

签名

时间日期相关方法

Index

Constants

View Source
const (
	ErrCodeOK                 = 0
	ErrCodeInvalidCredential  = 40001 // access_token 过期错误码
	ErrCodeAccessTokenExpired = 42001 // access_token 过期错误码
)

Variables

This section is empty.

Functions

func AESDecryptMsg

func AESDecryptMsg(ciphertext []byte, aesKey []byte) (random, rawXMLMsg, appID []byte, err error)

AESDecryptMsg ciphertext = AES_Encrypt[random(16B) + msg_len(4B) + rawXMLMsg + appId] 参考:github.com/chanxuehong/wechat.v2

func AESEncryptMsg

func AESEncryptMsg(random, rawXMLMsg []byte, appID string, aesKey []byte) (ciphertext []byte)

AESEncryptMsg ciphertext = AES_Encrypt[random(16B) + msg_len(4B) + rawXMLMsg + appId] 参考:github.com/chanxuehong/wechat.v2

func ArrayDefault

func ArrayDefault(str *[]string, defaultArray []string)

func Base64URLDecode

func Base64URLDecode(data string) ([]byte, error)

func Base64UrlSafeEncode

func Base64UrlSafeEncode(source []byte) string

func BoolDefault

func BoolDefault(str *bool, defaultBool bool)

func DecryptMsg

func DecryptMsg(appID, encryptedMsg, aesKey string) (random, rawMsgXMLBytes []byte, err error)

消息解密

func EncryptMsg

func EncryptMsg(random, rawXMLMsg []byte, appID, aesKey string) (encryptMsg []byte, err error)

加密消息

func GetCurTs

func GetCurTs() int64

获取当前时间戳

func HTTPGet

func HTTPGet(uri string, proxyAddr string) ([]byte, error)

HTTPGet get 请求

func Int64Default

func Int64Default(str *int64, defaultInt64 int64)

func Int8Default

func Int8Default(str *int8, defaultInt int8)

func IntDefault

func IntDefault(str *int, defaultInt int)

func LevelDefault added in v1.1.0

func LevelDefault(str *flog.LEVEL, defaultLevel flog.LEVEL)

func MD5Sum

func MD5Sum(txt string) (sum string)

MD5Sum 计算 32 位长度的 MD5 sum

func Mkdir

func Mkdir(dir string) (e error)

func PostFile

func PostFile(fieldname, filename, uri, proxyAddr string) (respBody []byte, err error)

PostFile 上传文件

func PostJSON

func PostJSON(uri string, obj interface{}, proxyAddr string) ([]byte, error)

PostJSON post json 数据请求

func PostMultipartForm

func PostMultipartForm(fields []MultipartFormField, uri string, proxyAddr string) (respBody []byte, err error)

PostMultipartForm 上传文件或其他多个字段

func RandomString

func RandomString(lenth int) string

func SHA1

func SHA1(str string) string

func Signature

func Signature(params ...string) string

sha1签名

func StrDefault

func StrDefault(str *string, defaultStr string)

func URLKVString

func URLKVString(m map[string]string) (s string)

Types

type MultipartFormField

type MultipartFormField struct {
	IsFile    bool
	Fieldname string
	Value     []byte
	Filename  string
}

MultipartFormField 保存文件或其他字段信息

type WxError

type WxError struct {
	ErrCode int64  `json:"errcode"`
	ErrMsg  string `json:"errmsg"`
}

微信返回通用错误json

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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