Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PasswordHash not working with CodeIgniter

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.

like image 431
Aniket Avatar asked Dec 05 '25 18:12

Aniket


2 Answers

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.

like image 128
Mathew Avatar answered Dec 07 '25 15:12

Mathew


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.

like image 37
OverZealous Avatar answered Dec 07 '25 15:12

OverZealous