鍏蜂綋鍙傝冿細(xì)http://www.lamppr.com/node/620
瀹炵幇閾炬帴鐨勮秴鏃跺け鏁堢瓥鐣ワ紝nginx閫氳繃Secure Link鏉ュ疄鐜般?br />鍏蜂綋鍙傝冿細(xì)
http://www.xsdou.com/1734.html
鐢變簬緗戜笂璇寸殑瀹炵幇浠g爜閮芥槸鍩轟簬PHP鐨勶紝鎵浠ュ湪榪欐垜鐢↗AVA瀹炵幇浜?jiǎn)涓嬨?br /><?php
$secret = 'password'; # 瀵嗛挜
$path = '/download/she.flv'; # 涓嬭澆鏂囦歡
$ipkey= md5("password".$_SERVER['REMOTE_ADDR']); #鍔犲瘑IP
# 涓嬭澆鍒版湡鏃墮棿,time鏄綋鍓嶆椂闂?300琛ㄧず300縐?涔熷氨鏄浠庣幇鍦ㄥ埌300縐掍箣鍐呮枃浠朵笉榪囨湡
$expire = time()+300;
# 鐢ㄦ枃浠惰礬寰勩佸瘑閽ャ佽繃鏈熸椂闂寸敓鎴愬姞瀵嗕覆
$md5 = base64_encode(md5($secret . $path . $expire, true));
$md5 = strtr($md5, '+/', '-_');
$md5 = str_replace('=', '', $md5);
# 鍔犲瘑鍚庣殑涓嬭澆鍦板潃
echo '<a href=http://s1.xsdou.com/download/she.flv?key='.$ipkey.'&st='.$md5.'&e='.$expire.'>she.flv</a>';
echo '<br>http://s1.xsdou.com/download/she.flv?key='.$ipkey.'&st='.$md5.'&e='.$expire;
?>
public static void main(String[] args) {
String secret = "password";
String path = "/mp4files/1162000000062C6B/221.194.64.19/2/45a594b6938698f63b5771c12ff5b912.mp4";
String expire = String.valueOf(System.currentTimeMillis() / 1000 + 600);
String remoteIp = "192.168.1.145";
String ipkey = DigestUtils.md5Hex(secret + remoteIp);
String st = new sun.misc.BASE64Encoder().encode(DigestUtils.md5(secret + path + expire)).replaceAll("\\+/", "-_").replaceAll("=", "");
System.out.println("ipkey: " + ipkey);
System.out.println("st: " + st);
System.out.println("e: " + expire);
}

]]>