While developing a small script to simulate MSFT Smooth Streaming client behavior, I needed to decrypt AES-128 encrypted manifest files. This task which seemed to be complex at first, turned out to be rather easy. Below is the sample code, to use with Python 2.6.5
from Crypto.Cipher import AES
#make iv a 16 bytes byte array
toStr = lambda x: "".join([chr(int(x[i:i+2])) for i in range(0,len(x),2)])
iv = toStr(myDic["iv"])
#"key" is the 16 bytes decryption key that you got from your key server.
decryptor = AES.new(key, AES.MODE_CBC, iv)
decrypted_manifest = decryptor.decrypt(encrypted_manifest)
No comments:
Post a Comment