How to generate encrypt signature in Elixir

How to generate encrypt signature in Elixir

Description
Elixir script to generate encrypt signature based on other languages scripts found here. Hope it’s useful for someone :slight_smile:

defmodule MyZoomApp.GenerateSignature do
  def perform(api_key, api_secret, meeting_number, role) do
    ts =
      UTCDateTime.utc_now()
      |> UTCDateTime.to_epoch(:unix, :millisecond)
             |> Kernel.-(30000)

    msg = :base64.encode("#{api_key}#{meeting_number}#{ts}#{role}")

    hmac =
      :sha256
       |> :crypto.hmac(api_secret, msg)
               |> :base64.encode

    :base64.encode("#{api_key}.#{meeting_number}.#{ts}.#{role}.#{hmac}")
  end
end
1 Like

Awesome! Thank you for sharing this @latte.software.

Max

1 Like