PasswordHash 无法与 CodeIgniter 一起使用
我已将从 http://www.openwall.com/phpass/ 下载的文件放到 < code>application/libraries
在我的控制器中,我正在使用此代码 -
$params = array(
'phpass_hash_strength' => 8,
'phpass_hash_portable' => FALSE
);
$this->load->library('PasswordHash', $params);
$password = $this->passwordhash->HashPassword($pwd);
我收到这些错误 -
A PHP Error was encountered
Severity: Notice
Message: Uninitialized string offset: 3
Filename: libraries/PasswordHash.php
Line Number: 116
A PHP Error was encountered
Severity: Warning
Message: strpos() [function.strpos]: Empty delimiter
Filename: libraries/PasswordHash.php
Line Number: 116
更新
已删除 PasswordHash.php
,现在使用 SimpleLoginSecure。
I have put the files I downloaded from http://www.openwall.com/phpass/ to application/libraries
In my controller, I am using this code -
$params = array(
'phpass_hash_strength' => 8,
'phpass_hash_portable' => FALSE
);
$this->load->library('PasswordHash', $params);
$password = $this->passwordhash->HashPassword($pwd);
I am getting these errors -
A PHP Error was encountered
Severity: Notice
Message: Uninitialized string offset: 3
Filename: libraries/PasswordHash.php
Line Number: 116
A PHP Error was encountered
Severity: Warning
Message: strpos() [function.strpos]: Empty delimiter
Filename: libraries/PasswordHash.php
Line Number: 116
Update
Removed PasswordHash.php
, using SimpleLoginSecure now.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我在将PasswordHash集成到Symfony2时遇到了同样的问题。
为了解决这个问题,我将
PasswordHash
方法重命名为__construct
。理论上,如果 PHP 5+ 找不到构造函数,则应该寻找与类同名的方法(http://php.net/manual/en/language.oop5.decon.php)。我的猜测是,一旦添加了命名空间(我的集成的要求),类名就会以不同的方式解析,但我根本没有调查过。
I had the same issue whilst integrating PasswordHash into Symfony2.
To solve it, I renamed the
PasswordHash
method to__construct
.In theory, PHP 5+ should look for a method with the same name as the class if it can't find a constructor (http://php.net/manual/en/language.oop5.decon.php). My guess is that the class name resolves differently once a namespace is added (a requirement for my integration), but I've not investigated at all.
我认为你的问题是你正在尝试使用通用 PHP 对象作为 CodeIgniter 库。你不能这么做。您需要修改原始代码才能工作,或者下载贡献的代码之一已经为 CodeIgniter 设计的库。
CodeIgniter 库有一些限制(例如它们的实例化方式),因此仅将任何文件放入库文件夹中是行不通的。
I think your problem is you are trying to use a generic PHP object as a CodeIgniter library. You can't just do that. You'll need to modify the original code to work, or download one of the contributed libraries already designed for CodeIgniter.
CodeIgniter libraries have some restrictions (such as how they are instantiated), so just dropping any file into the libraries folder won't work.