Authsome::hash PHP Метод

hash() публичный статический Метод

public static hash ( $password, $method = 'md5', $salt = false )
    public static function hash($password, $method = 'md5', $salt = false)
    {
        return Security::hash($password, $method, $salt);
    }

Usage Example

Пример #1
0
 function authsomeLogin($type, $credentials = array())
 {
     switch ($type) {
         case 'guest':
             // You can return any non-null value here, if you don't
             // have a guest account, just return an empty array
             return array();
         case 'credentials':
             $password = Authsome::hash($credentials['password'], Configure::read('SparkPlug.hash.method'), Configure::read('SparkPlug.hash.salt'));
             // This is the logic for validating the login
             $conditions = array('User.username' => $credentials['username'], 'User.password' => $password, 'User.active' => '1');
             break;
         case 'cookie':
             list($token, $userId) = split(':', $credentials['token']);
             $duration = $credentials['duration'];
             $loginToken = $this->LoginToken->find('first', array('conditions' => array('user_id' => $userId, 'token' => $token, 'duration' => $duration, 'used' => false, 'expires <=' => date('Y-m-d H:i:s', strtotime($duration))), 'contain' => false));
             if (!$loginToken) {
                 return false;
             }
             $loginToken['LoginToken']['used'] = true;
             $this->LoginToken->save($loginToken);
             $conditions = array('User.id' => $loginToken['LoginToken']['user_id']);
             break;
         default:
             return null;
     }
     return $this->find('first', compact('conditions'));
 }
All Usage Examples Of Authsome::hash