tencent cloud

Game Multimedia Engine

Release Notes
Product Introduction
Overview
Strengths
Features
Scenarios
Compliance
User Tutorial
Billing
Free Plan
Purchase Guide
SDK Download Guide
Product Feature Demo
Basic Feature Demo
Scenario-Specific Demo
Console Guide
Usage Querying
Activating Services
Getting Started
Quick Integration of SDK
Quick Integration of Sample Project
Basic Feature Development Guide
Authentication Key
Voice Chat Role Configuration
Sound Quality
Advanced Feature Development Guide
Server-Side Recording
Range Voice
3D Sound Effect
Sound Effect and Accompaniment
Network Audio Stream Forwarding Routing
Custom Message Channel
How to deal with the restrictions of corporate firewall
Language Parameter Reference List
Integrating GME Chat Room Management
Client API
SDK for Unity
SDK for Unreal Engine
Cocos2D SDK
SDK for Windows
SDK for iOS
SDK for Android
SDK for macOS
H5 SDK
Electron SDK
SDK for Flutter
SDK Version Upgrade Guide
Error Codes
Toolchain
Server APIs
History
Introduction
API Category
Usage APIs
Recording APIs
Making API Requests
Voice Chat APIs
Application APIs
Data Types
Error Codes
FAQ
Product Features
Troubleshooting Guide
Billing
Sample Project Usage
General
Authentication
Voice Chat Room Entry Failure
Sound and Audio
Network
Speech-to-text Conversion
Program Export
Service Agreement
Service Level Agreement
Contact Us
Glossary
GME Policy
Data Privacy and Security Agreement
Privacy Policy

Authentication Key

PDF
포커스 모드
폰트 크기
마지막 업데이트 시간: 2024-01-18 11:56:22
This document describes the authentication key for all platforms to help you integrate and debug GME.

Backend Deployment of Voice Key

GME provides authentication keys for voice chat and offline voice. This document describes the backend deployment scheme. The generation process of the signature used for authentication involves plaintext, secret key and algorithm.

Plaintext

The plaintext is the concatenation of the following fields in endian byte order:
Field
Type/Length
Description
cVer
unsigned char(1)
Version number. Enter 1.
wOpenIDLen
unsigned short(2)
User account length
strOpenID
string
User account's characters
dwSdkAppid
unsigned short(4)
SDKappid of the developer
dwReserved1
unsigned int(4)
Enter 0.
dwExpTime
unsigned int(4)
Expiration time (current time + validity period) in seconds. 300 is recommended.
dwReserved2
unsigned int(4)
Enter -1 or 0xFFFFFFFF.
dwReserved3
unsigned int(4)
Enter 0.
wRoomIDLen
unsigned short(2)
Length of the ID of the room to enter. Enter 0 for the voice messaging service.
strRoomID
string
Characters of the ID of the room to enter

Key

Get the relevant permission key in the GME console.

Algorithm

The Tiny Encryption Algorithm (TEA) symmetric algorithm is used. Generally, we recommend that you use the client deployment scheme in the initial stage, which later can be optimized for deployment on the game application's backend.
Scheme
Pros
Cons
Backend deployment
High security
Backend development and joint testing required
Client deployment
Quick integration
Low security

Backend Deployment

The encrypted string generated on the backend is sent to the client and used for the following scenario: When the EnterRoom API is called for entering a room, the encrypted string will be transferred to the authBuffer field in the parameters for room entering.

Algorithm Encryption Details

Key: Authentication key of APPID.
Encryption algorithm: TEA.
Note:
Change of the key in the console takes effect within 15 minutes to 1 hour. We recommend that you not change it frequently.

Encryption method

1. Reorganize the numbers in the plaintext in endian order.
2. Concatenate the plaintext fields into a string in the sequence how they are declared.
3. Encrypt the concatenated string with TEA. The string output by the symmetry_encrypt function is the permission encryption string.
Note:
Do not convert a binary string into a hexadecimal one.

Sample code

Taking C++ as an example, below is the sample code of the authentication key:
unsigned char pInBuf[512]={0};
xel::byte_writer bw(pInBuf, sizeof(pInBuf));

char cVer = 1;
unsigned short wOpenIDLen = (unsigned short)strlen((const char *)strOpenID);
if (wOpenIDLen > 127) wOpenIDLen = 127;
unsigned short wRoomIDLen = (unsigned short)strlen((const char *)strRoomID);
if (wRoomIDLen > 127) wRoomIDLen = 127;

bw.write_byte(cVer);
bw.write_int16(wOpenIDLen);
bw.write_bytes(strOpenID, wOpenIDLen);
bw.write_int32(dwSdkAppId);
bw.write_int32(0 /*dwRoomID*/);
bw.write_int32(expTime);
bw.write_int32(nAuthBits);
bw.write_int32(0 /*dwAccountType*/);
bw.write_int16(wRoomIDLen);
bw.write_bytes(strRoomID, wRoomIDLen);

int pInLen = bw.bytes_write();

unsigned char pEncryptOutBuf[512] = { 0 };
int iEncrptyLen = 0;

symmetry_encrypt((const unsigned char*)pInBuf, pInLen, (const unsigned char*)key, (unsigned char*)pEncryptOutBuf, &iEncrptyLen);
You can also download the sample code in Java and Go here.

도움말 및 지원

문제 해결에 도움이 되었나요?

피드백