久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在 Cakephp 2.x 的 Auth 組件中使用 Md5 進(jìn)行密碼哈希

Using Md5 for password hash in Auth component of Cakephp 2.x(在 Cakephp 2.x 的 Auth 組件中使用 Md5 進(jìn)行密碼哈希)
本文介紹了在 Cakephp 2.x 的 Auth 組件中使用 Md5 進(jìn)行密碼哈希的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我有一個(gè)現(xiàn)有的網(wǎng)站,使用 CakePhp 1.3 構(gòu)建.在那個(gè)網(wǎng)站上,我使用了 MD5 算法作為密碼哈希.

I have an existing website, built using CakePhp 1.3. In that website I have used MD5 algorithm for the password hash.

現(xiàn)在我想將我的 CakePhp 版本升級到 2.3.5,但我無法將 MD5 用于密碼哈希.

Now I want to upgrade my CakePhp version to 2.3.5, but I'm unable to use MD5 for the password hash.

我想知道為什么我不能在 CakePhp 2.x 中使用 MD5.?

I would like to know why I can't use MD5 in CakePhp 2.x. ?

推薦答案

不要使用 md5 作為密碼

md5 不是用于散列密碼的合適散列算法,請勿使用它.有很多很多參考資料可以解釋原因 - 包括 php手冊:

MD5、SHA1 和 SHA256 等哈希算法旨在非常快速和高效.借助現(xiàn)代技術(shù)和計(jì)算機(jī)設(shè)備,蠻力"這些算法的輸出以確定原始輸入已變得微不足道.

Why are common hashing functions such as md5() and sha1() unsuitable for passwords?

Hashing algorithms such as MD5, SHA1 and SHA256 are designed to be very fast and efficient. With modern techniques and computer equipment, it has become trivial to "brute force" the output of these algorithms, in order to determine the original input.

由于現(xiàn)代計(jì)算機(jī)反轉(zhuǎn)"這些散列算法的速度有多快,許多安全專家強(qiáng)烈建議不要使用它們進(jìn)行密碼散列.

Because of how quickly a modern computer can "reverse" these hashing algorithms, many security professionals strongly suggest against their use for password hashing.

如何更改默認(rèn)哈希算法

您可以使用 setHash,一種推薦的哈希算法密碼是河豚:

Security::setHash('blowfish');

如何處理現(xiàn)有密碼

如果你真的想,你可以改變 setHash 使用 md5.

但這不是一個(gè)好主意.

不要為了適應(yīng)舊應(yīng)用程序糟糕的安全性而損害新應(yīng)用程序/更新應(yīng)用程序的安全性.您可以使用如下邏輯(偽代碼):

Don't compromise the security of a new/updated application just to accommodate the poor security of the old one. Instead of using the same hash algoritm (and salt) as the previous application you can use logic such as the following (pseudo-ish code):

$username = $this->data['User']['username'];
$plainText = $this->data['User']['password'];

$user = current($this->User->findByUsername($username));

Security::setHash('blowfish');
$blowfished = Security::hash($plainText, 'blowfish', $user['password']);

if ($blowfished === $user['password']) {
    return true; // user exists, password is correct
}

$oldSalt = Configure::read('configure.this');
$md5ed = Security::hash($plainText, 'md5', $oldSalt);

if ($md5ed === $user['password']) {
    $this->User->id = $user['id'];

    $blowfished = Security::hash($plainText);
    $this->User->saveField('password', $blowfished);

    return true; // user exists, password now updated to blowfish
}

return false; // user's password does not exist.

這種邏輯并不復(fù)雜,可以避免繼續(xù)使用糟糕的哈希算法.

This kind of logic is not complex, and prevents the need to continue using a bad hash algorithm.

這篇關(guān)于在 Cakephp 2.x 的 Auth 組件中使用 Md5 進(jìn)行密碼哈希的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Session is lost after an OAuth redirect(OAuth 重定向后會(huì)話丟失)
Pagination Sort in Cakephp 3.x(Cakephp 3.x 中的分頁排序)
CakePHP Shared core for multiple apps(CakePHP 多個(gè)應(yīng)用程序的共享核心)
Login [ Auth-gt;identify() ] always false on CakePHP 3(在 CakePHP 3 上登錄 [ Auth-identify() ] 始終為 false)
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 87 bytes)(致命錯(cuò)誤:允許的內(nèi)存大小為 134217728 字節(jié)已用盡(嘗試分配 87 字節(jié)))
主站蜘蛛池模板: 依人成人| 国产亚洲精品一区二区三区 | 91在线一区二区三区 | 国产精品高清一区二区三区 | 国产精品高清一区二区 | 蜜桃视频一区二区三区 | 国产一区二区精品自拍 | 欧美不卡 | 能看的av网站 | 91视频精选 | 91精品欧美久久久久久久 | 在线观看第一区 | 国产一区二区三区四区五区加勒比 | 亚洲第一av | 国产精品成人一区二区三区 | 亚洲天堂一区二区 | 中文字幕一二三 | 999久久久免费精品国产 | 国产精品视频在线播放 | 青青草这里只有精品 | 国产黄色大片 | 亚洲高清在线观看 | 欧美精品一区二区在线观看 | 亚洲成人中文字幕 | 99久久婷婷国产综合精品电影 | 五月天婷婷激情 | 日p视频免费看 | 草久视频 | 国产亚洲精品久久久久动 | 在线播放91| 欧美一区二区免费视频 | 国产亚洲一区精品 | 成人在线一区二区 | 久久人人爽人人爽 | 日本免费小视频 | 九九热精品在线 | 久久国产精品72免费观看 | 国产91视频播放 | 国产精品免费一区二区 | 亚洲黄色av网站 | 亚洲电影一区二区三区 |