I need to check a password's validity in php. The password was hashed in django with a pbkdf2 hasher with the hashing algorithm as sha256.
https://gist.github.com/staydecent/1019680 <- This person was able to do the same with a simpler sha1 hash.
Verifying Django Password in Ruby on Rails gives non-matching password <- This person had a similar problem in ruby, instead of php.
As I understand it, django passwords are stored so that the hash style is the first component, the number of replications comes next, then then the salt, then the hash.
I have successfully extracted each component, but the following php does not work. It returns a string of the correct length, but not the correct content. I am fearful that the hash code does not work. The hasher I am using is from this website: https://defuse.ca/php-pbkdf2.htm
This is my php:
//$enc_password is the password from database
$pieces = explode('$', $enc_password);
$iterations = $pieces[1];
$salt = $pieces[2];
$hash = $pieces[3];
//raw_password is user's entered password
if ($hash == base64_encode(pbkdf2("sha256", $raw_password, $salt, $iterations, 32, true)))
{
echo ("SUCCESS");
}
else
{
echo ("FAILED");
}
Any and all help is appreciated!!