CoreFiles by mySites.guru
Signature.php87 lines, 1,764 bytes, from Joomla_4.4.14-Stable-Full_Package.zip
Raw History Compare with 4.4.13
md5
72718ae1c4c1ad3191f02434053a96d9
sha1
371b9b027bbe46e69c2e3bab2b574cbc4b61219f
sha256
1bb7b7b1c8aa9abfca11bfe703d2619f2bb33644e46d5d3d3d02c8e40660cc4a
<?php
/**
 * This file is part of Lcobucci\JWT, a simple library to handle JWT and JWS
 *
 * @license http://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
 */

namespace Lcobucci\JWT;

use Lcobucci\JWT\Signer\Key;

/**
 * This class represents a token signature
 *
 * @author Luís Otávio Cobucci Oblonczyk <[email protected]>
 * @since 0.1.0
 */
class Signature
{
    /**
     * The resultant hash
     *
     * @var string
     */
    protected $hash;

    /** @var string */
    private $encoded;

    /**
     * Initializes the object
     *
     * @param string $hash
     * @param string $encoded
     */
    public function __construct($hash, $encoded = '')
    {
        $this->hash    = $hash;
        $this->encoded = $encoded;
    }

    /** @return self */
    public static function fromEmptyData()
    {
        return new self('', '');
    }

    /**
     * Verifies if the current hash matches with with the result of the creation of
     * a new signature with given data
     *
     * @param Signer $signer
     * @param string $payload
     * @param Key|string $key
     *
     * @return boolean
     */
    public function verify(Signer $signer, $payload, $key)
    {
        return $signer->verify($this->hash, $payload, $key);
    }

    /**
     * Returns the current hash as a string representation of the signature
     *
     * @deprecated This method has been removed from the public API in v4
     * @see Signature::hash()
     *
     * @return string
     */
    public function __toString()
    {
        return $this->hash;
    }

    /** @return string */
    public function hash()
    {
        return $this->hash;
    }

    /** @return string */
    public function toString()
    {
        return $this->encoded;
    }
}

The same content is in 75 releases, Joomla 4.2.0-beta3 to 4.4.14. See them all, or every version of this file.