Media encryption and decryption for WhatsApp CDN payloads.
Summary
Functions
Decrypt downloaded media after verifying its WhatsApp media MAC.
Encrypt media into a temporary file while computing the WhatsApp media hashes and MAC in a single pass.
Types
@type encrypt_result() :: %{ encrypted_path: String.t(), media_key: binary(), file_sha256: binary(), file_enc_sha256: binary(), file_length: non_neg_integer() }
Functions
@spec decrypt(binary(), binary(), BaileysEx.Media.Types.media_type()) :: {:ok, binary()} | {:error, term()}
Decrypt downloaded media after verifying its WhatsApp media MAC.
@spec encrypt( binary() | Enumerable.t(), BaileysEx.Media.Types.media_type(), keyword() ) :: {:ok, encrypt_result()} | {:error, term()}
Encrypt media into a temporary file while computing the WhatsApp media hashes and MAC in a single pass.