3 # Allow direct execution
7 sys
.path
.insert(0, os
.path
.dirname(os
.path
.dirname(os
.path
.abspath(__file__
))))
13 from yt_dlp
.aes
import aes_encrypt
, key_expansion
15 secret_msg
= b
'Secret message goes here'
18 def hex_str(int_list
):
19 return codecs
.encode(bytes(int_list
), 'hex')
22 def openssl_encode(algo
, key
, iv
):
23 cmd
= ['openssl', 'enc', '-e', '-' + algo
, '-K', hex_str(key
), '-iv', hex_str(iv
)]
24 prog
= subprocess
.Popen(cmd
, stdin
=subprocess
.PIPE
, stdout
=subprocess
.PIPE
)
25 out
, _
= prog
.communicate(secret_msg
)
29 iv
= key
= [0x20, 0x15] + 14 * [0]
31 r
= openssl_encode('aes-128-cbc', key
, iv
)
32 print('aes_cbc_decrypt')
36 new_key
= aes_encrypt(password
, key_expansion(password
))
37 r
= openssl_encode('aes-128-ctr', new_key
, iv
)
38 print('aes_decrypt_text 16')
41 password
= key
+ 16 * [0]
42 new_key
= aes_encrypt(password
, key_expansion(password
)) * (32 // 16)
43 r
= openssl_encode('aes-256-ctr', new_key
, iv
)
44 print('aes_decrypt_text 32')