diff --git a/bypy/bypy.py b/bypy/bypy.py index 9b9f0eaae51ae7b28f3e3ab0302134375a78b3f8..0760ba5cbfb0392c6841ecad191645ca0e6170b7 100755 --- a/bypy/bypy.py +++ b/bypy/bypy.py @@ -3614,7 +3614,7 @@ def printBaiduBanner(): !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Baidu PCS currently gives totally WRONG MD5 hash for remote files, and I AM NOT GOING TO ADAPT TO IT! -So it if doesn't work, install version '1.6.10' using the following command: +So if it doesn't work, install version '1.6.10' using the following command: pip install bypy==1.6.10 Version 1.6.10 has a workaround for this. ### Seeking maintainer for this `bypy` project, if you are interested, please create an issue at github, thanks. ### diff --git a/bypy/cached.py b/bypy/cached.py index 032793aa3a5db1005b49e55bc03e4db540f20833..c413ecbcbb4862294802019fc4b643535aab4b06 100644 --- a/bypy/cached.py +++ b/bypy/cached.py @@ -299,19 +299,18 @@ def md5(filename, slice = const.OneM): return encrypt_md5(m.hexdigest()) -@cached def encrypt_md5(md5str): - if len(md5str)!=32: - return md5str - for i in range(0,32): - v = int(md5str[i],16) - if v<0 or v>16: + if len(md5str) != 32: + return md5str + for i in range(32): + v = int(md5str[i], 16) + if v < 0 or v > 16: return md5str md5str = md5str[8:16] + md5str[0:8] + md5str[24:32] + md5str[16:24] - encryptstr = "" - for e in range(0,len(md5str)): - encryptstr += hex(int(md5str[e],16) ^ 15 & e)[2:3] - return encryptstr[0:9] + chr(ord("g")+int(encryptstr[9],16)) + encryptstr[10:] + encryptstr = '' + for e in range(len(md5str)): + encryptstr += hex(int(md5str[e], 16) ^ 15 & e)[2:3] + return encryptstr[0:9] + chr(ord('g')+int(encryptstr[9], 16)) + encryptstr[10:] # slice md5 for baidu rapidupload @cached