crypto

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package crypto provides AES-128-ECB encryption/decryption for WeChat CDN media.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeAESKey

func DecodeAESKey(encoded string) ([]byte, error)

DecodeAESKey decodes an aes_key from the protocol. Handles: direct hex (32 chars), base64(raw 16 bytes), base64(hex string 32 chars).

func DecryptAESECB

func DecryptAESECB(ciphertext, key []byte) ([]byte, error)

DecryptAESECB decrypts AES-128-ECB ciphertext and removes PKCS7 padding.

func EncodeAESKeyBase64

func EncodeAESKeyBase64(key []byte) string

EncodeAESKeyBase64 returns base64(hex) for CDNMedia.aes_key.

func EncodeAESKeyHex

func EncodeAESKeyHex(key []byte) string

EncodeAESKeyHex returns the hex string of a key (for getuploadurl).

func EncryptAESECB

func EncryptAESECB(plaintext, key []byte) ([]byte, error)

EncryptAESECB encrypts plaintext with AES-128-ECB and PKCS7 padding.

func EncryptedSize

func EncryptedSize(rawSize int) int

EncryptedSize calculates the size after AES-128-ECB with PKCS7 padding.

func GenerateAESKey

func GenerateAESKey() ([]byte, error)

GenerateAESKey generates a random 16-byte AES key.

Types

This section is empty.

Jump to

Keyboard shortcuts

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