signature.php 607 B

123456789101112131415161718
  1. <?php
  2. // by 请勿倒卖,已申请软著,否则追究法律责任
  3. namespace app\aliyunoss;
  4. class signature
  5. {
  6. function index()
  7. {
  8. $str = json_encode(array("expiration" => date('Y-m-d', strtotime('+1 day')) . "T12:00:00.000Z", "conditions" => array(array("content-length-range", 0, 1048576000))));
  9. $str = base64_encode($str);
  10. $data['AccessKeyId'] = IN_ALIYUNOSS_AKI;
  11. $data['domain'] = (is_ssl() ? 'https://' : 'http://') . IN_ALIYUNOSS_BK . '.' . IN_ALIYUNOSS_EP;
  12. $data['policy'] = $str;
  13. $data['signature'] = base64_encode(hash_hmac("sha1", $str, IN_ALIYUNOSS_AKS, true));
  14. reJSON($data);
  15. }
  16. }