Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AESECBDecrypt ¶
AESECBDecrypt decrypts AES-128-ECB ciphertext and removes PKCS7 padding.
func AESECBEncrypt ¶
AESECBEncrypt encrypts plaintext with AES-128-ECB and PKCS7 padding.
func AESECBPaddedSize ¶
AESECBPaddedSize returns the ciphertext size after PKCS7 padding for AES-128-ECB.
func ParseAESKey ¶
ParseAESKey decodes a base64-encoded AES key, handling two formats:
Format 1: base64(raw 16 bytes) — commonly used for images Format 2: base64(hex string of 32 chars) — commonly used for files/voice/video
Types ¶
type Downloader ¶
type Downloader struct {
// contains filtered or unexported fields
}
Downloader downloads and decrypts files from the WeChat CDN.
func NewDownloader ¶
func NewDownloader(doer client.HTTPDoer) *Downloader
NewDownloader creates a Downloader with the given HTTP doer.
type Uploader ¶
type Uploader struct {
// contains filtered or unexported fields
}
Uploader uploads encrypted files to the WeChat CDN.
func NewUploader ¶
func NewUploader(c *client.Client, opts ...UploaderOption) *Uploader
NewUploader creates an Uploader for the given client.
func (*Uploader) Upload ¶
func (u *Uploader) Upload(ctx context.Context, data []byte, toUserID string, mediaType int) (*types.UploadedFileInfo, error)
Upload encrypts and uploads data to the CDN.
func (*Uploader) UploadFile ¶
func (u *Uploader) UploadFile(ctx context.Context, filePath, toUserID string, mediaType int) (*types.UploadedFileInfo, error)
UploadFile reads a file from disk and uploads it to the CDN.
type UploaderOption ¶
type UploaderOption func(*Uploader)
UploaderOption configures an Uploader.
func WithMaxRetries ¶
func WithMaxRetries(n int) UploaderOption
WithMaxRetries sets the maximum number of retries for 5xx errors.