replaced "blowfish" with "pycryptodome" for faster decryption
This commit is contained in:
parent
2d366fdc71
commit
61c2a337d7
|
@ -2,7 +2,7 @@
|
|||
import binascii
|
||||
import hashlib
|
||||
|
||||
import blowfish
|
||||
from Crypto.Cipher import Blowfish
|
||||
import pyaes
|
||||
import requests
|
||||
|
||||
|
@ -241,24 +241,26 @@ class Deezer:
|
|||
def decrypt_track(self, track_id, input, output):
|
||||
response = open(input, 'rb')
|
||||
outfile = open(output, 'wb')
|
||||
cipher = blowfish.Cipher(str.encode(self._get_blowfish_key(str(track_id))))
|
||||
blowfish_key = str.encode(self._get_blowfish_key(str(track_id)))
|
||||
blowfish = Blowfish.new(blowfish_key, Blowfish.MODE_CBC, b"\x00\x01\x02\x03\x04\x05\x06\x07")
|
||||
i = 0
|
||||
while True:
|
||||
chunk = response.read(2048)
|
||||
if not chunk:
|
||||
break
|
||||
if (i % 3) == 0 and len(chunk) == 2048:
|
||||
chunk = b"".join(cipher.decrypt_cbc(chunk, b"\x00\x01\x02\x03\x04\x05\x06\x07"))
|
||||
chunk = blowfish.decrypt(chunk)
|
||||
outfile.write(chunk)
|
||||
i += 1
|
||||
|
||||
def stream_track(self, track_id, url, stream):
|
||||
request = requests.get(url, stream=True)
|
||||
cipher = blowfish.Cipher(str.encode(self._get_blowfish_key(str(track_id))))
|
||||
blowfish_key = str.encode(self._get_blowfish_key(str(track_id)))
|
||||
blowfish = Blowfish.new(blowfish_key, Blowfish.MODE_CBC, b"\x00\x01\x02\x03\x04\x05\x06\x07")
|
||||
i = 0
|
||||
for chunk in request.iter_content(2048):
|
||||
if (i % 3) == 0 and len(chunk) == 2048:
|
||||
chunk = b"".join(cipher.decrypt_cbc(chunk, b"\x00\x01\x02\x03\x04\x05\x06\x07"))
|
||||
chunk = blowfish.decrypt(chunk)
|
||||
stream.write(chunk)
|
||||
i += 1
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
pyaes
|
||||
blowfish
|
||||
pycryptodome
|
||||
mutagen
|
||||
click
|
||||
requests
|
||||
|
|
Loading…
Reference in New Issue