简体   繁体   English

控制器的不同哈希算法

[英]different hash algorithm for controllers

How to change CakePHP 2.0 AuthComponent hash algorithm? 如何更改CakePHP 2.0 AuthComponent哈希算法? And, How to set different algorithm for different controllers (for example, users uses sha1 and customers uses md5) 并且,如何为不同的控制器设置不同的算法(例如, users使用sha1, customers使用md5)

I've read that article , but when I tested it in my cakephp 2.0 app, it said: 我已经读过该文章 ,但是当我在cakephp 2.0应用程序中对其进行测试时,它说:

Fatal error: Cannot use object of type User as array in *******\lib\Cake\Controller\Component\AuthComponent.php on line 661

thanks 谢谢

That article would have worked for version 1.3, but it looks like they've upgraded the AuthComponent. 该文章适用于1.3版,但看起来他们已经升级了AuthComponent。 You can read all about it here http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html?highlight=authentication 您可以在此处阅读有关此内容的所有信息:http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html?highlight=authentication

About half-way down the page they describe how you can set up your own custom hashing function as a beforeSave. 在页面的大约一半处,它们描述了如何将自己的自定义哈希函数设置为beforeSave。 For your situation, you would define the beforeSave of your User model to use the SHA1 algorithm, and so on for each different model. 根据您的情况,您将定义User模型的beforeSave以使用SHA1算法,对于每个不同的模型,依此类推。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM