private function genToken($tokenLen = null)
	{
		$this->debug->groupCollapsed(__METHOD__);
		$tokenLen = isset($tokenLen)
			? $tokenLen
			: $this->cfg['tokenLen'];
		$token = '';
		if (function_exists('mcrypt_create_iv') && !defined('PHALANGER')) {
			$token = mcrypt_create_iv($tokenLen, MCRYPT_DEV_URANDOM);
		}
		if (empty($token) && function_exists('openssl_random_pseudo_bytes')) {
			$token = openssl_random_pseudo_bytes($tokenLen);
		}
		if (empty($token) && is_readable('/dev/urandom')) {
			$file = fopen('/dev/urandom', 'r');
			$len = strlen($token);
			while ($len < $tokenLen) {
				$token .= fread($file, $tokenLen - $len);
				$len = strlen($token);
			}
			fclose($file);
		}
		$this->debug->log('token', $token);
		$this->debug->groupEnd();
		return $token;
	}