Appendix A (Data Encryption / Decryption)

To secure your Biz data with data encryption

Data Encryption Process with API Transaction Data

As our API protocol, The Transaction Data within API need to be encrypted in AES methodology which encryption mode is ECB and fill mode is PKCS5 Padding.

☑️ Encryption STEPS:

  1. Sort the data (JSON data format) in dictionary order by their key name, then concatenate their corresponding value into one data string.

  2. Calculate the MD5 value of the data string from step one, and then convert to uppercase. This value will be also passed in as one of the HTTP request parameters.

  3. Concatenate the MD5 value from the STEP 2 and merchant encryption key (signkey) provided by OTT

  4. Perform the MD5 16-bit calculation, and then uppercase it again as AES key

  5. Perform AES and Base64 encryption to the data string

☑️ Encryption Example:

Here is the original transaction data (JSON data format) as below,

{'orderId' : '1234567890', 'idCardName' : ‘张三‘, 'idCardNum' : '123456789012345678', 'bankCardNum' : '62000000000010', 'mobile' : '13711111111', 'idCardType' : '1'}

1️⃣ After Step-1 sorting and concatenate:

62000000000010张三1234567890123456781137111111111234567890

2️ After Step-2 MD5 calculation:

C12F9560769C2CB55E6954935B325916

3️⃣ After Step-3 (Merchant SignKey:6698851A525C9433):

C12F9560769C2CB55E6954935B3259166698851A525C9433

4️⃣ After Step 4: Get AES Key

5️⃣ After Step 5: get Encrypted String

Data Decryption Process with API Transaction Data

Response/Call-Back API Transaction data is encrypted in AES methodology which encryption mode is ECB and fill mode is PKCS5 Padding.

☑️ Decryption STEPS:

  1. get the data field string value from response/call-back payload parameters level data.

  2. get the md5 field string value from response/call-back payload parameters level data

  3. Get AES key by above above md5 string and merchant signkey provided by OTT Pay

  4. Apply Base64 decoding and Decrypt the step-2 result by using the AES key get from Step 3.

☑️Decryption Example:

Here is the response message with transaction data (JSON data format) as below,

1️⃣ After Step-1 data string value:

2️ After Step-2 MD5 string value:

3️⃣ After Step 3: Get AES Key(Merchant SignKey: 6698851A525C9433):

4️⃣ After Step 4: Base64 decoding and decrypted String:

Code Samples (Payment Request API)

Here are code samples in different development languages.

Last updated

Was this helpful?