我想用Python3使用事件API。在當前狀態下,登錄功能使用不推薦使用的md5庫。因此,我想將此函數轉換爲Python 3兼容。我與面臨困境的線是:Python3:用hashlib替換md5
response = md5.new(nonce + ':'+ md5.new(password).hexdigest()).hexdigest()
我嘗試將其轉換爲
mpwd = hashlib.md5(password.encode())
apwd = mpwd.hexdigest()
s = nonce+":"+apwd
mall = hashlib.md5(s.encode())
response = mall.hexdigest()
不幸的是,API返回的說,無論是登錄或密碼不正確的錯誤。但是,我檢查了兩個都沒問題。那麼請你告訴我我的代碼有什麼問題嗎?
,如果你在你的答案重寫代碼它的更好,將與其中的變化 – Michael