MD5 Signature Generation Rules
The sub-account module of the VOD system and the retrieval of video playback credentials use the MD5 signature rule. Most other VOD modules use the SHA1 signature rule for signing. The details are as follows:
- Obtain the key signature information for the sub-account appid and secretkey. Log in to the official website -> Select any VOD function -> Settings -> Account Management -> Select the sub-account modification function (if there is no sub-account, add one), as shown below:
Note: Only sub-accounts with the content distribution role have appid and secretkey.



- Use the MD5 signature algorithm to generate the signature. The specific encryption calculation method is as follows:
2.1 Arrange the required request parameters (parameters with non-null values) in dictionary order by parameter name, and concatenate the parameter name with its value. For example: ts1552447784505userIde6b23c6f51videoIde6b23c6f51c4b1cb9f0302a92ed42440_eviewerIdabcd1234viewerIp127.0.0.1;
2.2 Add the secretKey to both the beginning and end of the concatenated string. Taking secretKey as abc as an example, the result is: abcts1552447784505userIde6b23c6f51videoIde6b23c6f51c4b1cb9f0302a92ed42440_eviewerIdabcd1234viewerIp127.0.0.1abc
2.3 Then, use UTF-8 encoding to calculate the MD5 value, and convert the MD5 result to uppercase letters as the sign.
Common Issues:
Parameters with null values were not excluded during string concatenation.
The character set used for signing must be UTF-8. If not specified, the platform's default character set may be used, leading to errors.
For quick integration of the basic code, please download the relevant dependency source code. Click here to download the source code. After downloading, add it to your own source code project. The test cases HttpUtil.java and VodSignUtil.java are included in the downloaded file.
It is strongly recommended that you use the VOD Java SDK to complete API function integration. The VOD Java SDK provides a unified encapsulation and optimization for API call logic, exception handling, data signing, and HTTP request thread pooling.
package net.polyv.common;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import net.polyv.util.VodSignUtil;
/**
* @author: thomas
**/
public class VodSignTest {
private static final Logger log = LoggerFactory.getLogger(VodSignTest.class);
@Test
public void buildSubSign() throws UnsupportedEncodingException, NoSuchAlgorithmException {
String appid = "XXXXXXXX";
String secretkey = "XXXXXXXXXXXXXXXXXXXXXXXX";
long timestamp = System.currentTimeMillis();
Map<String, String> paramMap = new HashMap<String, String>();
//公共参数
paramMap.put("appId", appid);
paramMap.put("timestamp", Long.toString(timestamp));
//业务参数
paramMap.put("vid","1b448be3233659acf35d430ba9210bd4_1");
String sign = VodSignUtil.getSignMd5(paramMap, secretkey);
log.debug("生成签名:{}",sign);
}
}
