Generate a hidden field with the current CSRF token.

@return string
779781
public function token()
    {
        if (empty($this->csrfToken) && !is_null($this->session)) {
            $this->csrfToken = $this->session->token();
        }

        return $this->hidden('_token', $this->csrfToken);
    }
1193827
public static function getStoredToken(): Token
    {
        if (static::$token !== null) {
            return static::$token;
        }

        $sessionKeyName = static::getSessionKeyName();

        if ($sessionKeyName === null || strlen($sessionKeyName) == 0) {
            throw new Exception('Can not get stored CSRF token when session key is not set');
        }

        $token = Session::get($sessionKeyName);

        if ($token === null) {
            throw new SecurityException('There is no stored token on backend');
        }

        static::$token = $token;
        return $token;
    }
1256008
public static function formToken()
    {
        // <input type="hidden" name="xsrf" value=" . self::getToken() . " />
        $obj = new XMLElement("input");
        $obj->setAttribute("type", "hidden");
        $obj->setAttribute("name", "xsrf");
        $obj->setAttribute("value", self::getToken());
        return $obj;
    }
105583
public function getCsrfToken() {
		if (!isset($_SESSION[$this->csrfTokenSessionKey])) {
			$this->generateCsrfToken();
		}
		return $_SESSION[$this->csrfTokenSessionKey];
	}
431460
protected function getCsrfToken(): ?string
    {
        if (is_null($this->csrfToken)) {
            $this->csrfToken = $this->app->make('session')->token();
        }

        return $this->csrfToken;
    }
743489
public function getCode()
    {
        $html = $this->form;

        if ($this->meta->checks['honeypots'])
        {
            $html = $this->createHoneypots($html, $this->honeypots);
        }

        $botoborData =
            '<div style="display: none;">' .
            $this->createInput('hidden', Botobor::META_FIELD_NAME, $this->meta->getEncoded()) .
            '</div>';

        $html = preg_replace('/(<form[^>]*>)/si', '$1'.$botoborData, $html);

        return $html;
    }
1363452
protected function uneditableField()
	{
		echo $this->getLabel();
		echo '<div class="controls">';
		echo CHtml::tag('span', $this->htmlOptions, $this->model->{$this->attribute});
		echo $this->getError() . $this->getHint();
		echo '</div>';
	}
781488
public function generate()
    {
        return sprintf(
            '<input type="hidden" id="ctrl_%s" name="%s" value="%s" /><div%s>%s</div>',
            $this->strId,
            $this->strName,
            StringUtil::specialchars($this->label ?: $this->varValue),
            $this->style ? ' style="' . $this->style . '"' : '',
            $this->label
        );
    }
1301783
public static function generateCsrfToken()
  {
    if (version_compare(PHP_VERSION, '7.0.0', '>=')) {
      $_SESSION['csrf_token'] = bin2hex(random_bytes(32));
    } elseif(version_compare(PHP_VERSION, '7.0.0', '<')) {
      if (function_exists('mcrypt_create_iv')) {
        $_SESSION['csrf_token'] = bin2hex(mcrypt_create_iv(32, MCRYPT_DEV_URANDOM));
      } else {
        $_SESSION['csrf_token'] = bin2hex(openssl_random_pseudo_bytes(32));
      }
    }
    return "<input id='csrf_token' type='hidden' name='csrf_token' value='{$_SESSION['csrf_token']}'>";
  }
530604
public static function token()
    {
        self::$csrfToken = !empty(self::$csrfToken) ? self::$csrfToken : Session::token();

        return self::hidden('_token', self::$csrfToken);
    }
565452
public function createCsrfField()
    {
        $fieldName = Config::get('security.csrf.field_name');

        $input = new Input($this->form->expression('input'), [
            'name' => $fieldName,
            'value' => $this->createToken(),
            'type' => 'hidden'
        ]);

        return $input->execute();
    }
981138
public static function getCsrfToken(): string
    {
        if (!self::has('CSRF_TOKEN')) {
            self::put('CSRF_TOKEN', Str::random(32));
        }

        return self::get('CSRF_TOKEN');
    }
518129
public static function getCSRFToken() {
        $allHeaders = array_change_key_case(parent::getHeaders(), CASE_UPPER);

        if (array_key_exists('X-CSRF-TOKEN', $allHeaders)) {
            return $allHeaders['X-CSRF-TOKEN'];
        } else {
            throw new \Exception(ExceptionMessages::CSRF_TOKEN_NOT_FOUND);
        }
    }
276564
protected function renderTrustedPropertiesField()
    {
        $formFieldNames = $this->viewHelperVariableContainer->get(\Neos\FluidAdaptor\ViewHelpers\FormViewHelper::class, 'formFieldNames');
        $requestHash = $this->mvcPropertyMappingConfigurationService->generateTrustedPropertiesToken($formFieldNames, $this->getFieldNamePrefix());
        return '<input type="hidden" name="' . $this->prefixFieldName('__trustedProperties') . '" value="' . htmlspecialchars($requestHash) . '" />' . chr(10);
    }
71301
protected function renderHiddenInput()
    {
        if ($this->hasModel()) {
            return Html::activeHiddenInput($this->model, $this->attribute, $this->inputOptions);
        } else {
            return Html::hiddenInput($this->name, $this->value, $this->inputOptions);
        }
    }
1267554
private function addCSRFTokenField()
    {
        $this->nonceValue = $this->createNonce();
        $nonce = new FormField(FormField::TYPE_HIDDEN);
        $nonce
            ->setName('nonce')
            ->setValue($this->createNonce())
            ->setValidationCallback(
                function ($value) {
                    if (function_exists('wp_verify_nonce')) {
                        if (!wp_verify_nonce($value, $this->nonceKey)) {
                            throw new \Exception('Unauthorized request');
                        }
                    } // Use own csrf token
                    else {
                        if (!isset($_SESSION['csrf_tokens'][$value])) {
                            throw new \Exception('Unauthorized request');
                        } else {
                            unset($_SESSION['csrf_tokens'][$value]);
                        }
                    }

                    return false;
                }
            )
            ->setMandatory(true);
        $key = 'nonce';

        $this->addField($key, $nonce);
    }
843731
public static function generateToken()
    {
        $raw = self::getOpenSSLRandom();
        if (false === $raw) {
            $raw = self::getComplexRandom();
        }
        return md5($raw);
    }