我正在導出,通過與http請求刮,因爲主機不會給我數據庫訪問,論壇和導入到一個MySQL數據庫vbulletin。Python是從PHP生成的鹽,並存儲在Mysql
在vBulletin用戶擁有唯一的密碼鹽,並生成使用該算法的密碼哈希值:
$hash = md5(md5($plaintext) . $salt);
我使用python腳本從用戶信息我的SQLite數據庫讀取存儲數據,以產生新密碼和salt,然後將這些數據存儲到mysql數據庫中,以便vbulletin可以使用它。
我的問題是,python以意想不到的方式改變字符串的值。我正在測試我的腳本,使用已知的密碼和鹽來比較哈希值。但是,我使用的鹽是這樣的:
D(A\3*w/lo6Coo\Mc,[email protected]&R
當我試圖存儲在蟒蛇,當我檢索字符串我得到這個:
D(A\x03*w/lo6Coo\\Mc,[email protected]&R
這是Python代碼我使用模仿vBulletin哈希算法「M:
salt = 'D(A\3*w/lo6Coo\Mc,[email protected]&R'
password = hashlib.md5()
password.update('*snipped password*')
password = password.hexdigest()
password_hash = hashlib.md5()
password_hash.update(password + salt)
password_hash = password_hash.hexdigest()
爲了比較,這個PHP匹配什麼vBulletin存儲在數據庫中的密碼哈希:
$plaintext = '*snipped password*';
$salt = 'D(A\3*w/lo6Coo\Mc,[email protected]&R';
$hash = md5(md5($plaintext) . $salt);
$ hash與vbulletin存儲和password_hash不匹配。我做錯了什麼導致差異?
我發誓,我已經嘗試過爲原料和Unicode都在這裏發帖之前,並沒有工作,但現在它的工作原理。謝謝您的幫助。 –