util

package
v0.0.0-...-acd4438 Latest Latest
Warning

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

Go to latest
Published: May 26, 2015 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

提供一些实用函数

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AESDecryptMsg

func AESDecryptMsg(encryptedMsg []byte, AppId string, AESKey [32]byte) (random, rawXMLMsg []byte, err error)

encryptedMsg = AES_Encrypt[random(16B) + msg_len(4B) + rawXMLMsg + AppId]

func AESEncryptMsg

func AESEncryptMsg(random, rawXMLMsg []byte, AppId string, AESKey [32]byte) (encryptedMsg []byte)

encryptedMsg = AES_Encrypt[random(16B) + msg_len(4B) + rawXMLMsg + AppId]

func AESKeyDecode

func AESKeyDecode(encodedAESKey string) (AESKey []byte, err error)

把长度为 43 的字符串 base64 decode 到 32 字节的 []byte

encodedAESKey 由 a-z,A-Z,0-9 组成, 一般在微信管理后台随机生成

func Bool

func Bool(v bool) *bool

Bool is a helper routine that allocates a new bool value to store v and returns a pointer to it.

func Download

func Download(url, filepath string, httpClient *http.Client) (err error)

func DownloadToWriter

func DownloadToWriter(url string, w io.Writer, httpClient *http.Client) (err error)

func Float32

func Float32(v float32) *float32

Float32 is a helper routine that allocates a new float32 value to store v and returns a pointer to it.

func Float64

func Float64(v float64) *float64

Float64 is a helper routine that allocates a new float64 value to store v and returns a pointer to it.

func HttpResponseWriter

func HttpResponseWriter(w io.Writer) http.ResponseWriter

将 io.Writer 从语义上实现 http.ResponseWriter.

func Int

func Int(v int) *int

Int is a helper routine that allocates a new int value to store v and returns a pointer to it.

func Int32

func Int32(v int32) *int32

Int32 is a helper routine that allocates a new int32 value to store v and returns a pointer to it.

func Int64

func Int64(v int64) *int64

Int64 is a helper routine that allocates a new int64 value to store v and returns a pointer to it.

func MsgSign

func MsgSign(token, timestamp, nonce, encryptedMsg string) (signature string)

微信公众号/企业号 密文模式消息签名

func Sign

func Sign(token, timestamp, nonce string) (signature string)

微信公众号 明文模式/URL认证 签名

func String

func String(v string) *string

String is a helper routine that allocates a new string value to store v and returns a pointer to it.

func Uint32

func Uint32(v uint32) *uint32

Uint32 is a helper routine that allocates a new uint32 value to store v and returns a pointer to it.

func Uint64

func Uint64(v uint64) *uint64

Uint64 is a helper routine that allocates a new uint64 value to store v and returns a pointer to it.

func WXVersion

func WXVersion(userAgent string) (x, y, z int, err error)

获取微信客户端的版本.

userAgent: 微信内置浏览器的 user-agent;
x, y, z:   如果微信版本为 5.3.1 则有 x==5, y==3, z==1
err:       错误信息

Types

This section is empty.

Jump to

Keyboard shortcuts

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