utils

package
v0.0.0-...-2b36f50 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2022 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SignTypeMD5        = `MD5`
	SignTypeHMACSHA256 = `HMAC-SHA256`
)

微信签名算法方式

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 AesECBDecrypt

func AesECBDecrypt(ciphertext []byte, aesKey []byte) ([]byte, error)

AesECBDecrypt will decrypt data with PKCS5Padding

func CalculateSign

func CalculateSign(content, signType, key string) (string, error)

CalculateSign 计算签名

func DecryptAES256GCM

func DecryptAES256GCM(aesKey, associatedData, nonce, ciphertext string, dest interface{}) error

DecryptAES256GCM aesKey 密钥 associatedData 附加数据 ciphertext 数据密文 nonce 加密使用的随机串

func DecryptMsg

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

DecryptMsg 消息解密

func EncryptMsg

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

EncryptMsg 加密消息

func HttpGet

func HttpGet(url string) ([]byte, error)

func HttpPost

func HttpPost(url string, header http.Header, data []byte) ([]byte, error)

func HttpPostForm

func HttpPostForm(url string, header http.Header, data map[string]string, files ...File) ([]byte, error)

func MD5

func MD5(data string) string

MD5加密

func NewECBDecryptor

func NewECBDecryptor(b cipher.Block) cipher.BlockMode

NewECBDecryptor returns a BlockMode which decrypts in electronic code book mode, using the given Block.

func NewECBEncryptor

func NewECBEncryptor(b cipher.Block) cipher.BlockMode

NewECBEncryptor returns a BlockMode which encrypts in electronic code book mode, using the given Block.

func PKCS5Padding

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

PKCS5Padding -

func PKCS5UnPadding

func PKCS5UnPadding(origData []byte) []byte

PKCS5UnPadding -

func RandInt

func RandInt(max int) int

func RandRange

func RandRange(min, max int) (int, bool)

func RandString

func RandString(length int) string

func Sha1

func Sha1(data string) string

Sha1 加密

Types

type CDATAInt

type CDATAInt int

func (CDATAInt) MarshalXML

func (c CDATAInt) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (CDATAInt) String

func (c CDATAInt) String() string

type CDATAStr

type CDATAStr string

func (CDATAStr) MarshalXML

func (c CDATAStr) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (CDATAStr) String

func (s CDATAStr) String() string

type ECBDecryptor

type ECBDecryptor ecb

ECBDecryptor -

func (*ECBDecryptor) BlockSize

func (x *ECBDecryptor) BlockSize() int

BlockSize implement BlockMode.BlockSize

func (*ECBDecryptor) CryptBlocks

func (x *ECBDecryptor) CryptBlocks(dst, src []byte)

CryptBlocks implement BlockMode.CryptBlocks

type ECBEncryptor

type ECBEncryptor ecb

ECBEncryptor -

func (*ECBEncryptor) BlockSize

func (x *ECBEncryptor) BlockSize() int

BlockSize implement BlockMode.BlockSize

func (*ECBEncryptor) CryptBlocks

func (x *ECBEncryptor) CryptBlocks(dst, src []byte)

CryptBlocks implement BlockMode.CryptBlocks

type File

type File interface {
	GetFieldName() string
	GetName() string
	GetData() *os.File
}

Jump to

Keyboard shortcuts

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