I have been doing some testing while coding a secure auth system, and I'm left slightly confused and have some questions!
Here's how I have security setup in DI
protected function security()
{
$config = $this->_config;
$this->_di->set('security', function() use ($config) {
$security = new \Phalcon\Security();
$security->setWorkFactor($config->auth->hash_workload);
$security->setDefaultHash(\Phalcon\Security::CRYPT_BLOWFISH_Y);
return $security;
});
}
Now in my Auth library I use return $this->_security->checkHash($str, $hash);
and providing my user provides the correct password, they are authenticated. However, in PHP5.5 bcrypt functionality has been builtin as standard and in my Auth library I can also use return password_verify($str, $hash);
and this will also authenticate my user. So what exactly is the difference between using PHP5.5 password_hash() and password_verify() and Phalcon's hash() and checkHash()? And given that the native php functions and the phalcon functions are both compiled in C, is there any advantage to using the phalcon methods?
Also another thing I find weired is that if I change setWorkFactor and setDefaultHash settings, my user still gets authenticated, but surelly these settings should have completely changed the hashing algorithm, so my user shoulkd nolonger be authenticated. What am I missing here?