.ts 文件 解密 程序

#
#
# .ts 文件 解密 程序 
#
# 2023-10-29 Win10 Python 3.6.0 调试 成功.
#
# 下载 .ts 文件 和 key.key 文件 不写了,
#
# 需要 下载 一个 pycryptodome 的库, 命令如下:
#
# pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pycryptodome
#

# 解密后 ts视频文件就可播放.
#
#
#
#


#
#
# .ts 文件 解密 程序 
#
# 2023-10-29 Win10 Python 3.6.0 调试 成功.
#
# 下载 .ts 文件 和 key.key 文件 不写了,
#
# 需要 下载 一个 pycryptodome 的库, 命令如下:
#
# pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pycryptodome
#
# 
# 解密后 ts视频文件就可播放.
#
#
#
#

from Crypto.Cipher import AES
from Crypto.Util.Padding import pad, unpad
from Crypto.Random import get_random_bytes

def encrypt(plain_text, key):
    iv = get_random_bytes(AES.block_size)
    cipher = AES.new(key, AES.MODE_CBC, iv)
    cipher_text = cipher.encrypt(pad(plain_text, AES.block_size))
    return iv + cipher_text

def decrypt(cipher_text, key):
    iv = cipher_text[:AES.block_size]
    cipher = AES.new(key, AES.MODE_CBC, iv)
    plain_text = unpad(cipher.decrypt(cipher_text[AES.block_size:]), AES.block_size)
    return plain_text




fff='rWzBLNMX.ts'
keyf="key.txt"

fp = open(fff,"rb" )

html = fp.read()

#print (html)

fp.close()

fp = open(keyf,"rb" )

ks = fp.read()

print (ks)

fp.close()

decrypted_text = decrypt(html, ks)

print (decrypted_text)


outf='ttt.ts'
fo = open(outf,"wb" )

fo.write(decrypted_text)

fo.close()

print ("ts jie mi ok...")


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值