How to use Blowfish password hasher in cakephp


Posted on 14 May 15 by Vickey

Blowfish password hasher is very strong. it is very difficult to hack. you can use blowfish hasher by following these steps.

In your model add this code

public function beforeSave($options = array()) {

        if (isset($this->data[$this->alias]['password'])) {
            $passwordHasher = new BlowfishPasswordHasher();
            $this->data[$this->alias]['password'] = $passwordHasher->hash(

        return parent::beforeSave($options);

it will hash your password before save record

and for use blowfish hash password add this in auth component

public $components = array('Session', 'Cookie',
    'Auth' => array(

                'authenticate' => array(
                    'Form' => array(
                            'passwordHasher' => 'Blowfish',
                            'userModel' => 'User',
                            'fields' => array(
                            'username' => 'username',
                            'password' => 'password'


If this post help you reduce time to develop, you can help me to maintain this website :)