Skip to content

~.encrypt

Encrypt

Encrypt

Container class for all supported, non-deprecated encryption modes.

SUPPORTED class-attribute instance-attribute

SUPPORTED: tuple[str, ...] = (
    "aead_aes256_gcm_rtpsize",
    "aead_xchacha20_poly1305_rtpsize",
)

A list of all currently supported, non-deprecated, complete, and tested encryption modes.

decrypt_aead_aes256_gcm_rtpsize staticmethod

decrypt_aead_aes256_gcm_rtpsize(
    secret_key: bytes, audio: bytes
) -> bytes

Decrypt audio using aead_aes256_gcm_rtpsize.

PARAMETER DESCRIPTION
secret_key

32-byte AES encryption key provided by Discord.

TYPE: bytes

audio

Opus audio payload.

TYPE: bytes

RETURNS DESCRIPTION
bytes

The decrypted audio packet.

decrypt_aead_xchacha20_poly1305_rtpsize staticmethod

decrypt_aead_xchacha20_poly1305_rtpsize(
    secret_key: bytes, audio: bytes
) -> bytes

Decrypt audio using aead_xchacha20_poly1305_rtpsize.

PARAMETER DESCRIPTION
secret_key

32-byte AES encryption key provided by Discord.

TYPE: bytes

audio

Opus audio payload.

TYPE: bytes

RETURNS DESCRIPTION
bytes

The decrypted audio packet.

encrypt_aead_aes256_gcm_rtpsize staticmethod

encrypt_aead_aes256_gcm_rtpsize(
    secret_key: bytes,
    nonce: int,
    header: bytes,
    audio: bytes,
) -> bytes

Encrypt audio using aead_aes256_gcm_rtpsize.

PARAMETER DESCRIPTION
secret_key

32-byte AES encryption key provided by Discord.

TYPE: bytes

nonce

32-bit packet counter.

TYPE: int

header

RTP header (12 bytes).

TYPE: bytes

audio

Opus audio payload.

TYPE: bytes

RETURNS DESCRIPTION
bytes

The encrypted audio packet.

encrypt_aead_xchacha20_poly1305_rtpsize staticmethod

encrypt_aead_xchacha20_poly1305_rtpsize(
    secret_key: bytes,
    nonce: int,
    header: bytes,
    audio: bytes,
) -> bytes

Encrypt audio using aead_xchacha20_poly1305_rtpsize.

PARAMETER DESCRIPTION
secret_key

32-byte AES encryption key provided by Discord.

TYPE: bytes

nonce

32-bit packet counter.

TYPE: int

header

RTP header (12 bytes).

TYPE: bytes

audio

Opus audio payload.

TYPE: bytes

RETURNS DESCRIPTION
bytes

The encrypted audio packet.