PHP   发布时间:2022-04-09  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了如何替换cakephp密码哈希算法?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个现有的数据库,我正试图把蛋糕应用程序放在上面.旧的应用程序在Perl中使用crypt()来散列密码.我需要在 PHP应用程序中执行相同的操作.

在标准的cakePHP应用程序中进行更改的正确位置在哪里?这样的改变会是什么样的?

我搞定了……

这是我的AppController:

class AppController extends Controller {
    var $components = array('Auth');

    function beforeFilter() {
        // this is part of cake that serves up static pages,it should be authorized by default
        $this->Auth->allow('display');
        // tell cake to look on the user model itself for the password hashing function
        $this->Auth->authenticate = ClassRegistry::init('User');
        // tell cake where our credentials are on the User entity
        $this->Auth->fields = array(
           'username' => 'user','password' => 'pass',);
        // this is where we want to go after a login... we'll want to make this dynamic at some point
        $this->Auth->loginRedirect = array('controller'=>'users','action'=>'index');
    }
}@H_618_10@ 
 

然后这用户

<?PHP
class User extends AppModel {
    var $name = 'User';

    // this is used by the auth component to turn the password into its hash before comparing with the DB
    function hashpasswords($data) {
         $data['User']['pass'] = crypt($data['User']['pass'],substr($data['User']['user'],2));
         return $data;
    }
}
?>@H_618_10@ 
 

我认为其他一切都很正常.

这是一个很好的资源:http://teknoid.wordpress.com/2008/10/08/demystifying-auth-features-in-cakephp-12/

大佬总结

以上是大佬教程为你收集整理的如何替换cakephp密码哈希算法?全部内容,希望文章能够帮你解决如何替换cakephp密码哈希算法?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。