Skip to content

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:

ParameterDescriptionExample
agentAgent ID10001
paramEncrypted parameter stringZhm1p0RRzzI+3SFURqryL8...
timestampTimestamp1736751734
keyMD5 checksum string7295a7d851243e8af3c8439db44ceba0

🔐 Signing Algorithm & Example ​

📊 Parameter Encryption ​

Example of parameters that need to be encrypted:

ParameterDescriptionExample
sOperation subtype0
accountPlayer account111111
moneyAmount (used for deposits in Transfer Wallet mode; has no effect in Seamless Wallet mode)100
orderidTransaction ID10001202501130000001111111
ipClient request IP127.0.0.1
lineCodeSite identifier (optional)line01
KindIDGame ID1
currencyCurrencyCNY

🔒 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&currency=CNY

2. 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

javascript
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&currency=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 + MD5Key

2. MD5 encryption implementation

javascript
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

Input: 100011736751734405B856329C9D8YB
Output: ec9b5d714ab75cbe2dd7e15ae7443139

🔧 Complete Flow ​

Step-by-Step ​

1

Prepare interface parameters

Prepare the business parameters needed for the request

2

Build the parameter string

Combine the parameters into a Query String format

3

AES encryption

Encrypt with AES-128-ECB

4

Generate the MD5 checksum

Generate the checksum using agent + timestamp + MD5Key

5

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