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
14 from yt_dlp
.utils
import intlist_to_bytes
16 secret_msg
= b
'Secret message goes here'
19 def hex_str(int_list
):
20 return codecs
.encode(intlist_to_bytes(int_list
), 'hex')
23 def openssl_encode(algo
, key
, iv
):
24 cmd
= ['openssl', 'enc', '-e', '-' + algo
, '-K', hex_str(key
), '-iv', hex_str(iv
)]
25 prog
= subprocess
.Popen(cmd
, stdin
=subprocess
.PIPE
, stdout
=subprocess
.PIPE
)
26 out
, _
= prog
.communicate(secret_msg
)
30 iv
= key
= [0x20, 0x15] + 14 * [0]
32 r
= openssl_encode('aes-128-cbc', key
, iv
)
33 print('aes_cbc_decrypt')
37 new_key
= aes_encrypt(password
, key_expansion(password
))
38 r
= openssl_encode('aes-128-ctr', new_key
, iv
)
39 print('aes_decrypt_text 16')
42 password
= key
+ 16 * [0]
43 new_key
= aes_encrypt(password
, key_expansion(password
)) * (32 // 16)
44 r
= openssl_encode('aes-256-ctr', new_key
, iv
)
45 print('aes_decrypt_text 32')