#
#
# .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...")