Authentication
This chapter explains the platform's authentication mechanism, signing algorithm, and parameter encryption method in detail, to ensure the security of API communication.
🛠️ Required Interface Parameters
All interfaces that call the platform API must include the following parameters:
| Parameter | Description | Example |
|---|---|---|
agent | Agent ID | 10001 |
param | Encrypted parameter string | Zhm1p0RRzzI+3SFURqryL8... |
timestamp | Timestamp | 1736751734 |
key | MD5 checksum string | 7295a7d851243e8af3c8439db44ceba0 |
🔐 Signing Algorithm & Example
📊 Parameter Encryption
Example of parameters that need to be encrypted:
| Parameter | Description | Example |
|---|---|---|
s | Operation subtype | 0 |
account | Player account | 111111 |
money | Amount (used for deposits in Transfer Wallet mode; has no effect in Seamless Wallet mode) | 100 |
orderid | Transaction ID | 10001202501130000001111111 |
ip | Client request IP | 127.0.0.1 |
lineCode | Site identifier (optional) | line01 |
KindID | Game ID | 1 |
currency | Currency | CNY |
🔒 AES Encryption Process
1. Build the string to encrypt as a Query String
Combine the parameters into a string using the following format:
s=0&account=111111&money=100&orderid=10001202501130000001111111&ip=127.0.0.1&lineCode=line01&KindID=1¤cy=CNY2. Encrypt using AES-128-ECB
💡 AES Encryption Implementation
The platform uses AES-128-ECB mode to encrypt parameters; the key is provided by the platform
Example implementation
const crypto = require('crypto');
function aesEncrypt(param, desKey) {
let cipherChunks = [];
let cipher = crypto.createCipheriv('aes-128-ecb', desKey, '');
cipher.setAutoPadding(true);
cipherChunks.push(cipher.update(param, 'utf8', 'base64'));
cipherChunks.push(cipher.final('base64'));
return cipherChunks.join('');
}
// DESKey (provided by the platform)
const desKey = '9DA9A418752C85C7';
const paramString = 's=0&account=111111&money=100&orderid=10001202501130000001111111&ip=127.0.0.1&lineCode=line01&KindID=1¤cy=CNY';
const encryptedParam = aesEncrypt(paramString, desKey);
console.log(encryptedParam);3. Encryption result
Zhm1p0RRzzI+3SFURqryL819/70k20+XhLINyQ9flnH0kkHIDjfvn7tq1kh0jNN6MPYrW783Ae5tJ2rxpBdW/a3RUfO8G42eMfPgvt3muH85OAjw3acClpGoYWl/8qQ4Y1g1DGhOq9JDa1dNytrqh7I4uhv/Ki/AzntyT1o3lxI=🔐 MD5 Checksum
1. Build the string to hash
Concatenate the following parameters:
agent + timestamp + MD5Key2. MD5 encryption implementation
const crypto = require('crypto');
function md5Encrypt(agent, timestamp, md5Key) {
const concatenated = agent + timestamp + md5Key;
const hash = crypto
.createHash('md5')
.update(concatenated)
.digest('hex');
return hash;
}
// MD5Key (provided by the platform)
const md5Key = '405B856329C9D8YB';
// Example usage
const agent = '10001';
const timestamp = '1736751734';
const keyHash = md5Encrypt(agent, timestamp, md5Key);
console.log(keyHash);3. Encryption example
🔧 Complete Flow
Step-by-Step
Prepare interface parameters
Prepare the business parameters needed for the request
Build the parameter string
Combine the parameters into a Query String format
AES encryption
Encrypt with AES-128-ECB
Generate the MD5 checksum
Generate the checksum using agent + timestamp + MD5Key
Send the request
Include the four parameters: agent, param, timestamp, key
🔍 Notes
🔒 Security Reminder
- Protect your keys: Keep the AESKey and MD5Key secure and avoid leaking them
- Use HTTPS: All API requests must use the HTTPS protocol
- IP whitelist: Configure an IP whitelist to restrict request sources
- Logging: Log failed authentication requests to help with troubleshooting and security monitoring
