I am using http://www.openwall.com/phpass/ for hashing. I wish to add namespace to it, and added the single line as shown below.
<?php
namespace myNameSpace; //I added this one line
class PasswordHash {
//...
}
?>
I then create my object, however, when I apply the HashPassword method, the results are totally different.
require 'PasswordHash.php';
//$t_hasher = new PasswordHash(8, FALSE); //Original line
$t_hasher = new myNameSpace\PasswordHash(8, FALSE);
$correct = 'test12345';
$hash = $t_hasher->HashPassword($correct);
The only changes were the two lines where I added the namespace to the class and were I initiated the object.
What could cause the differences and how can identify and fix them?
Per the documentation https://www.php.net/__destruct
As of PHP 5.3.3, methods with the same name as the last element of a namespaced class name will no longer be treated as constructor. This change doesn't affect non-namespaced classes.
phpass uses a constructor with the same name as the last element of a namespaced class. Change the name to __construct
.