Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected $_saltLength = 50;
- protected $_saltChars = 'qwertyuiopasdfghjklzxcvbnm1234567890QWERTYUIOPASDFGHJKLZXCVBNM,.#!%*()-+=';
- /**
- * Hash the password and set the salt
- *
- * @see Model::beforeSave()
- */
- public function beforeSave()
- {
- if (isset($this->data['Member']['password']))
- {
- $salt = $this->_generateSalt();
- $this->data['Member']['salt'] = $salt;
- $this->data['Member']['password'] = sha1($salt . $this->data['Member']['password']);
- $this->data['Member']['status'] = self::STATUS_ACTIVE;
- }
- return true;
- }
- protected function _generateSalt()
- {
- for ($i = 0; $i < $this->_saltLength; $i++)
- {
- $str .= $this->_saltChars[rand(0, $this->_saltLength - 1)];
- }
- return $str;
- }
- }
Add Comment
Please, Sign In to add comment