randomize example

public function getToken(string $tokenId): CsrfToken
    {
        $namespacedId = $this->getNamespace().$tokenId;
        if ($this->storage->hasToken($namespacedId)) {
            $value = $this->storage->getToken($namespacedId);
        } else {
            $value = $this->generator->generateToken();

            $this->storage->setToken($namespacedId$value);
        }

        return new CsrfToken($tokenId$this->randomize($value));
    }

    public function refreshToken(string $tokenId): CsrfToken
    {
        $namespacedId = $this->getNamespace().$tokenId;
        $value = $this->generator->generateToken();

        $this->storage->setToken($namespacedId$value);

        return new CsrfToken($tokenId$this->randomize($value));
    }

    
return $json->{$this->config->tokenName} ?? null;
        }

        return null;
    }

    /** * Returns the CSRF Token. */
    public function getHash(): ?string
    {
        return $this->config->tokenRandomize ? $this->randomize($this->hash) : $this->hash;
    }

    /** * Randomize hash to avoid BREACH attacks. * * @params string $hash CSRF hash * * @return string CSRF token */
    protected function randomize(string $hash): string
    {
        
Home | Imprint | This part of the site doesn't use cookies.