最近项目需要用到腾讯云点播的一些功能,前后端交互进行视频的上传,后端使用python生成signature进行返回,因此记录一下签名的生成。
import base64
import hmac
import random
import time
from hashlib import sha1
class VodClient:
def __init__(self, secret_id: str, secret_key: str, exp_time: int = 7000):
"""
云点播签名文档:https://cloud.tencent.com/document/product/266/9221
签名工具:https://video.qcloud.com/signature/ugcgenerate.html?_ga=1.147964338.442939846.1570722999
签名校验:https://video.qcloud.com/signature/ugcdecode.html?_ga=1.186