[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/vendor/phpseclib/phpseclib/phpseclib/Math/Common/FiniteField/ -> Integer.php (source)

   1  <?php
   2  
   3  /**
   4   * Finite Field Integer Base Class
   5   *
   6   * PHP version 5 and 7
   7   *
   8   * @author    Jim Wigginton <terrafrost@php.net>
   9   * @copyright 2017 Jim Wigginton
  10   * @license   http://www.opensource.org/licenses/mit-license.html  MIT License
  11   */
  12  
  13  namespace phpseclib3\Math\Common\FiniteField;
  14  
  15  /**
  16   * Finite Field Integer
  17   *
  18   * @author  Jim Wigginton <terrafrost@php.net>
  19   */
  20  abstract class Integer implements \JsonSerializable
  21  {
  22      /**
  23       * JSON Serialize
  24       *
  25       * Will be called, automatically, when json_encode() is called on a BigInteger object.
  26       *
  27       * PHP Serialize isn't supported because unserializing would require the factory be
  28       * serialized as well and that just sounds like too much
  29       *
  30       * @return array{hex: string}
  31       */
  32      #[\ReturnTypeWillChange]
  33      public function jsonSerialize()
  34      {
  35          return ['hex' => $this->toHex(true)];
  36      }
  37  
  38      /**
  39       * Converts an Integer to a hex string (eg. base-16).
  40       *
  41       * @return string
  42       */
  43      abstract public function toHex();
  44  }