How to use Blowfish password hasher in cakephp

Cakephp

Posted on 14 May 15 by Vickey
  1481



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(
                $this->data[$this->alias]['password']
            );
        }

        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 :)
www.000webhost.com