Recently, when I used python to crawl ts type data, I found that the directly downloaded ts video could not be played normally. I boldly searched Baidu and found that it was caused by video encryption.After going through Baidu and Google, I came into contact with the pycrypto module, which is mainly used to decrypt encrypted videos.
Since the module was not installed smoothly, I stepped on a lot of pits.Because I know the pain, regret and trouble of stepping on the pit, I deliberately wrote an article to record the method of installing this module, so as to prevent people from jumping into the pit.
pip install pycryptodome
If there is no error when running the above command, then congratulations on your successful installation, you can go directly to the third link.
After running the pip command, it is found that the error message is displayed directly. The error message is as follows:
After some attempts, the solution is as follows:
Download and install visual studio, and install the components of c++ 14.0, as shown below.
If you run it again and it prompts gcc to report an error, congratulations!Won a jackpot!This is due to the configuration file in anaconda.Share here, the solution to this problem.
from Crypto.Cipher import AES# corresponding modulefrom Crypto.Util.Padding import pad#create parser#Note that the key needs to be in binary formcryptor = AES.new(key, AES.MODE_CBC, iv)# becomes a multiple of 16, some scenarios may require#encrypted_data = pad(string, 16)#data is the binary string that needs to be decryptedresult = cryptor.decrypt(data)