Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrPKCS7BlockSizeExceeded = errors.New("pkcs7: block size exceeded")
ErrPKCS7BlockSizeExceeded is an error that indicates that the block size exceeds the maximum length.
var ErrPKCS7IncorrectPadding = errors.New("pkcs7: incorrect padding")
ErrPKCS7IncorrectPadding is an error that indicates the padding is incorrect.
var ErrPKCS7PaddingLengthExceeded = errors.New("pkcs7: padding length exceeded")
ErrPKCS7PaddingLengthExceeded is an error that indicates that the length of the padding exceeds the total length.
Functions ¶
func PKCS7Padding ¶
PKCS7Padding pads a byte array using the PKCS#7 padding method.
The src parameter is the source byte array. The blockSize parameter is the block size. The dst parameter is the destination byte array. The err return value is an error.
func PKCS7Unpadding ¶
PKCS7Unpadding removes the padding bytes from a byte array that was padded using the PKCS#7 padding method.
The src parameter is the source byte array. The dst parameter is the destination byte array. The err return value is an error.
Types ¶
type AESUseCBCWithPKCS7 ¶
type AESUseCBCWithPKCS7 struct {
// contains filtered or unexported fields
}
AESUseCBCWithPKCS7 This will be filled using PKCS7 and finally encrypted using AES CBC mode
func NewAESUseCBCWithPKCS7 ¶
func NewAESUseCBCWithPKCS7(key, iv []byte) *AESUseCBCWithPKCS7
NewAESUseCBCWithPKCS7 creates a new AESUseCBCWithPKCS7 structure.
The key parameter is the key. The iv parameter is the initialization vector. The function returns a pointer to a new AESUseCBCWithPKCS7 structure.
type Crypto ¶
type Crypto interface { Encrypt(plain []byte) ([]byte, error) Decrypt(encrypt []byte) ([]byte, error) }
Crypto is an encryption and decryption interface for simple encapsulation
type WXCrypto ¶
type WXCrypto struct {
// contains filtered or unexported fields
}
WXCrypto 开放平台的消息加密解密技术方案基于 AES 加解密算法来实现,具体如下:
EncodingAESKey: 即消息加解密 Key,长度固定为 43 个字符,从 a-z,A-Z,0-9 共 62 个字符中选取。由开发者在创建公众号插件时填写,后也可申请修改。 AESKey: AESKey=Base64_Decode(EncodingAESKey + "="),EncodingAESKey 尾部填充一个字符的 "=", 用 Base64_Decode 生成 32 个字节的 AESKey; AES 采用 CBC 模式,秘钥长度为 32 个字节(256 位),数据采用 PKCS#7 填充; PKCS#7:K 为秘钥字节数(采用 32), Buf 为待加密的内容,N 为其字节数。Buf 需要被填充为 K 的整数倍。在 Buf 的尾部填充(K - N%K)个字节,每个字节的内容 是(K - N%K)。
func NewWXCrypto ¶
NewWXCrypto ...