PasswordHash 无法与 CodeIgniter 一起使用

发布于 2024-11-29 18:02:00 字数 896 浏览 2 评论 0原文

我已将从 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

小傻瓜 2024-12-06 18:02:00

我在将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.

一笔一画续写前缘 2024-12-06 18:02:00

我认为你的问题是你正在尝试使用通用 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文