generateSignature method

String generateSignature(
  1. String apiKey,
  2. String apiSecret,
  3. String meetingNumber,
  4. int role,
)

Generate Signatue for zoom signate required to perform join and start functions

Implementation

String generateSignature(
    String apiKey, String apiSecret, String meetingNumber, int role) {
  final timestamp = DateTime.now().millisecondsSinceEpoch - 30000;
  var str = '$apiKey$meetingNumber$timestamp$role';
  var bytes = utf8.encode(str);
  final msg = base64.encode(bytes);

  final key = utf8.encode(apiSecret);
  final hmacSha256 = Hmac(sha256, key); // HMAC-SHA256
  final digest = hmacSha256.convert(utf8.encode(msg));
  final hash = base64.encode(digest.bytes);

  str = '$apiKey.$meetingNumber.$timestamp.$role.$hash';
  bytes = utf8.encode(str);
  final signature = base64.encode(bytes);
  return signature.replaceAll(RegExp("="), "");
}