[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/vendor/lcobucci/jwt/src/Signer/ -> Hmac.php (source)

   1  <?php
   2  /**
   3   * This file is part of Lcobucci\JWT, a simple library to handle JWT and JWS
   4   *
   5   * @license http://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
   6   */
   7  
   8  namespace Lcobucci\JWT\Signer;
   9  
  10  /**
  11   * Base class for hmac signers
  12   *
  13   * @author Luís Otávio Cobucci Oblonczyk <[email protected]>
  14   * @since 0.1.0
  15   */
  16  abstract class Hmac extends BaseSigner
  17  {
  18      /**
  19       * {@inheritdoc}
  20       */
  21      public function createHash($payload, Key $key)
  22      {
  23          return hash_hmac($this->getAlgorithm(), $payload, $key->getContent(), true);
  24      }
  25  
  26      /**
  27       * {@inheritdoc}
  28       */
  29      public function doVerify($expected, $payload, Key $key)
  30      {
  31          if (!is_string($expected)) {
  32              return false;
  33          }
  34  
  35          return hash_equals($expected, $this->createHash($payload, $key));
  36      }
  37  
  38      /**
  39       * Returns the algorithm name
  40       *
  41       * @internal
  42       *
  43       * @return string
  44       */
  45      abstract public function getAlgorithm();
  46  }


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer