1 from __future__ import unicode_literals
8 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
10 from youtube_dl.utils import intlist_to_bytes
11 from youtube_dl.aes import aes_encrypt, key_expansion
13 secret_msg = b'Secret message goes here'
16 def hex_str(int_list):
17 return codecs.encode(intlist_to_bytes(int_list), 'hex')
20 def openssl_encode(algo, key, iv):
21 cmd = ['openssl', 'enc', '-e', '-' + algo, '-K', hex_str(key), '-iv', hex_str(iv)]
22 prog = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
23 out, _ = prog.communicate(secret_msg)
26 iv = key = [0x20, 0x15] + 14 * [0]
28 r = openssl_encode('aes-128-cbc', key, iv)
29 print('aes_cbc_decrypt')
33 new_key = aes_encrypt(password, key_expansion(password))
34 r = openssl_encode('aes-128-ctr', new_key, iv)
35 print('aes_decrypt_text 16')
38 password = key + 16 * [0]
39 new_key = aes_encrypt(password, key_expansion(password)) * (32 // 16)
40 r = openssl_encode('aes-256-ctr', new_key, iv)
41 print('aes_decrypt_text 32')