Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php namespace Pagekit\Session\Csrf\Provider; class DefaultCsrfProvider implements Csrf..
Decoded Output download
<?php
namespace Pagekit\Session\Csrf\Provider;
class DefaultCsrfProvider implements CsrfProviderInterface
{
/**
* @var string
*/
protected $name;
/**
* @var string
*/
protected $token;
/**
* Constructor.
*
* @param string $name
*/
public function __construct($name = '_csrf')
{
$this->name = $name;
}
/**
* {@inheritdoc}
*/
public function generate()
{
return sha1($this->getSessionId().$this->getSessionToken());
}
/**
* {@inheritdoc}
*/
public function validate($token = null)
{
if ($token === null) {
$token = $this->token;
}
return $token === $this->generate();
}
/**
* {@inheritdoc}
*/
public function setToken($token)
{
$this->token = $token;
}
/**
* Returns the session id.
*
* @return string
*/
protected function getSessionId()
{
if (!session_id()) {
session_start();
}
return session_id();
}
/**
* Returns the session token.
*
* @return string
*/
protected function getSessionToken()
{
if (!isset($_SESSION[$this->name])) {
$_SESSION[$this->name] = sha1(uniqid(rand(), true));
}
return $_SESSION[$this->name];
}
}
?>
Did this file decode correctly?
Original Code
<?php
namespace Pagekit\Session\Csrf\Provider;
class DefaultCsrfProvider implements CsrfProviderInterface
{
/**
* @var string
*/
protected $name;
/**
* @var string
*/
protected $token;
/**
* Constructor.
*
* @param string $name
*/
public function __construct($name = '_csrf')
{
$this->name = $name;
}
/**
* {@inheritdoc}
*/
public function generate()
{
return sha1($this->getSessionId().$this->getSessionToken());
}
/**
* {@inheritdoc}
*/
public function validate($token = null)
{
if ($token === null) {
$token = $this->token;
}
return $token === $this->generate();
}
/**
* {@inheritdoc}
*/
public function setToken($token)
{
$this->token = $token;
}
/**
* Returns the session id.
*
* @return string
*/
protected function getSessionId()
{
if (!session_id()) {
session_start();
}
return session_id();
}
/**
* Returns the session token.
*
* @return string
*/
protected function getSessionToken()
{
if (!isset($_SESSION[$this->name])) {
$_SESSION[$this->name] = sha1(uniqid(rand(), true));
}
return $_SESSION[$this->name];
}
}
Function Calls
None |
Stats
MD5 | 8050b953f931d030cb2a91275121612d |
Eval Count | 0 |
Decode Time | 106 ms |