Skip to content

Commit 87dda3f

Browse files
committed
Decryption issue fix
1 parent 075a6dd commit 87dda3f

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

pandas_datareader/yahoo/daily.py

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,11 @@
1818

1919
def decrypt_cryptojs_aes(data):
2020
encrypted_stores = data["context"]["dispatcher"]["stores"]
21-
_cs = data["_cs"]
22-
_cr = data["_cr"]
23-
24-
_cr = b"".join(
25-
int.to_bytes(i, length=4, byteorder="big", signed=True)
26-
for i in json.loads(_cr)["words"]
27-
)
28-
password = hashlib.pbkdf2_hmac("sha1", _cs.encode("utf8"), _cr, 1, dklen=32).hex()
21+
password_key = next(key for key in data.keys() if key not in ["context", "plugins"])
22+
password = data[password_key]
2923

3024
encrypted_stores = b64decode(encrypted_stores)
25+
3126
assert encrypted_stores[0:8] == b"Salted__"
3227
salt = encrypted_stores[8:16]
3328
encrypted_stores = encrypted_stores[16:]
@@ -229,11 +224,9 @@ def _read_one_data(self, url, params):
229224
try:
230225
j = json.loads(re.search(ptrn, resp.text, re.DOTALL).group(1))
231226

232-
if "_cs" in j and "_cr" in j:
233-
new_j = decrypt_cryptojs_aes(
234-
j
235-
) # returns j["context"]["dispatcher"]["stores"]
236-
# from old code
227+
new_j = decrypt_cryptojs_aes(
228+
j
229+
)
237230

238231
data = new_j["HistoricalPriceStore"]
239232

0 commit comments

Comments
 (0)