How to Set Life cycle for Download url

  java, question

Take the URL of BaiduMusic as an example:

http://music.baidu.com/data/music/file?link=http://zhangmenshiting.baidu.com/data2/music/23512929/58929231353722461.mp3?xcode=46916de5bb4f17904142dc87def856f4

How should we analyze this URL? Is link a document actual address? What is the purpose of xcode and how is it generated?

The link address is definitely not real, and the file name contains a certain cache_key, and the corresponding expire_time and other information can be found.

As for xcode, it may be calculated as follows:

Xcode = md5(cache_key plus secret_key)

The secret_key is only stored in the server, which ensures that the server can verify and the client cannot forge. In this way, the address cannot be downloaded after a certain period of time, thus avoiding problems such as external links.