Skip to main content

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:


_20
curl --location --request POST 'https://api.agora.io/api/speech-to-text/v1/projects/{appId}/join' \
_20
--header 'Content-Type: application/json' \
_20
--header 'Authorization: Basic <credentials>' \
_20
--data '{
_20
"name": "unique-agent-id",
_20
"languages": [
_20
"en-US"
_20
],
_20
"maxIdleTime": 50,
_20
"rtcConfig": {
_20
"channelName": "<YourChannelName>",
_20
"subBotUid": "<YourSubscribeUid>",
_20
"subBotToken": "<YourSubscribeToken>",
_20
"pubBotUid": "<YourPublishUid>",
_20
"pubBotToken": "<PublishToken-IfRequired>",
_20
"cryptionMode": 7,
_20
"secret": "32-byte-encryption-key",
_20
"salt": "base64-encoded-32-byte-salt-if-mode-7-or-8"
_20
}
_20
}'

Encryption mode

CodeEncryption methodDescription
0No Encryption
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.