miniproto.crypto.mtproto.media_ctr_crypt
miniproto.crypto.mtproto.media_ctr_crypt
Section titled “miniproto.crypto.mtproto.media_ctr_crypt”media_ctr_crypt(data: BytesLike, key: bytes, iv: bytes) -> bytesApply AES-256-CTR to CDN/media bytes.
Parameters:
- data (
BytesLike) – Bytes to encrypt or decrypt; CTR uses the same operation both ways. - key (
bytes) – Exactly 32 bytes of AES-256 key material. - iv (
bytes) – Exactly 16 bytes of counter/initialization value.
Returns:
bytes– Transformed bytes of the same length asdata.
Raises:
ValueError– If the key or IV length is invalid.
Reusing a key/IV pair across distinct plaintexts is unsafe; this wrapper does
not track nonce reuse. Dispatch can prefer the C-backed fallback when
cryptography is installed for the benchmarked media path.