0
我需要將cakephp 1.3中的表users
傳輸到另一個系統,但我們不希望重置用戶的所有密碼。 cakephp 1.3用來散列用戶密碼的算法如何工作?Cake 1.3使用哪個算法來散列密碼?
在此先感謝!
我需要將cakephp 1.3中的表users
傳輸到另一個系統,但我們不希望重置用戶的所有密碼。 cakephp 1.3用來散列用戶密碼的算法如何工作?Cake 1.3使用哪個算法來散列密碼?
在此先感謝!
呃......我認爲這比我想象的要簡單。
蛋糕認證要求從驗證密碼方法,然後從安全類調用哈希。
//Auth class
function password($password) {
return Security::hash($password, null, true);
}
在安全,默認情況下,它使用SHA1方法與鹽和密碼串接;鹽是蛋糕安裝過程中生成的一個隨機字符串,他的值寫在core.php文件中。
//Security class
function hash($string, $type = null, $salt = false) {
$_this = Security::getInstance();
if ($salt) {
if (is_string($salt)) {
$string = $salt . $string;
} else {
$string = Configure::read('Security.salt') . $string;
}
}
if (empty($type)) {
$type = $_this->hashType;
}
$type = strtolower($type);
if ($type == 'sha1' || $type == null) {
if (function_exists('sha1')) {
$return = sha1($string);
return $return;
}
$type = 'sha256';
}
//...
}
然後,我需要的是將此實現帶到下一個系統並標記來自新用戶的以前的用戶。首次登錄時,用戶將看到一個表單,使用新系統中的新哈希方法輸入新密碼。