BaileysEx.Media.Crypto (baileys_ex v0.1.0-alpha.9)

Copy Markdown View Source

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

encrypt_result()

@type encrypt_result() :: %{
  encrypted_path: String.t(),
  media_key: binary(),
  file_sha256: binary(),
  file_enc_sha256: binary(),
  file_length: non_neg_integer()
}

Functions

decrypt(encrypted_data, media_key, media_type)

@spec decrypt(binary(), binary(), BaileysEx.Media.Types.media_type()) ::
  {:ok, binary()} | {:error, term()}

Decrypt downloaded media after verifying its WhatsApp media MAC.

encrypt(input, media_type, opts \\ [])

@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.