Skip to main content

You are viewing Agora Docs forBetaproducts and features. Switch to Docs

Encrypt captions

Sometimes audio and video streams are encrypted for security reasons. In this case, Real-Time STT uses a key to decrypt the audio stream for transcription and then encrypt the captions in the data stream payload. The app then uses the same key to decrypt the data stream payload and extract the captions on the client's side.

This page explains how to implement caption text encryption in your app.

Prerequisites

To follow this procedure, you must:

  • Make sure Real-Time STT is enabled for your app.

  • Be using Video SDK for native platforms v4.2.6.3 or for web v4.20.1 with support for datastreamEncryptionEnabled.

Implementation

To encrypt the captions, follow the API call sequence from the REST Quickstart and modify the start request to include encryption parameters as follows:


_19
curl --location -g 'https://api.agora.io/v1/projects/{{appId}}/rtsc/speech-to-text/tasks?builderToken={{tokenName}}' \
_19
--header 'Content-Type: application/json' \
_19
--data '{
_19
{
_19
"languages": [
_19
"<YourTranscribeLanguages>"
_19
],
_19
"maxIdleTime": 50,
_19
"rtcConfig": {
_19
"channelName": "<YourChannelName>", // The RTC channel name.
_19
"subBotUid": "<YourSubscribeUid>", // The unique UID in the channel for the bot to subscribe to audio. Int UID needs to be filled as a string.
_19
"subBotToken": "<YourSubscribeToken>", // The RTC token for subBot to join the RTC channel. Optional, based on the RTC channel security configuration.
_19
"pubBotUid": "<YourPublishUid>", // The unique UID in the channel for the bot to publish text. Int UID needs to be filled as a string. subBotUid and pubBotUid MUST be different.
_19
"pubBotToken": "<YourPublishToken>", // The RTC token for pubBot to join the RTC channel. Apply the admin token. Optional, based on the RTC channel security configuration.
_19
"cryptionMode": <YourCryptionMode>, // The encryption mode (Optional), configure when the app needs encryption for the audio and caption text. If using Video SDK for Web, select 7 or 8.
_19
"secret": "<YourSecret>", // The encryption secret key, optional. Provided if decryption is needed for audio and encryption caption text. 32 bytes.
_19
"salt": "<YourSalt>", // Encryption salt, optional. If encryption mode is set to 7 or 8. Based64, 32 bytes. Agora recommends that you use OpenSSL to generate salt on the server side.
_19
},
_19
}

Encryption mode

CodeEncryption methodDescription
1AES_128_XTS128-bit AES encryption, XTS mode.
2AES_128_ECB128-bit AES encryption, ECB mode.
3AES_256_XTS256-bit AES encryption, XTS mode.
4SM4_128_ECB128-bit SM4 encryption, ECB mode.
5AES_128_GCM128-bit AES encryption, GCM mode.
6AES_256_GCM256-bit AES encryption, GCM mode.
7AES_128_GCM2128-bit AES encryption, GCM mode. Requires the setting of salt.
8AES_256_GCM2256-bit AES encryption, GCM mode. Requires the setting of salt.
vundefined