salt as table column

I have a table column called salt and it is a required field but I don’t want to users to input their own salts is there a way for our system to generate a salt for each password which are encrypted via sha1?

yes you could declare a beforeSave method in your user model like so

public function beforeSave()


    $this->password_hash = sha1($this->password);

    return parent::beforeSave();


for more details follow the link

Will this code put a generated salt in the salt column of our table?

depends how you have structured your users table, you have to test this

keep faith how you have organized your clients table, you need to test this

Just use bCrypt… problem solved!

Yii2 uses it by default.