Subversion Repositories oidplus

Rev

Rev 874 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  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.     #[\ReturnTypeWillChange]
  31.    public function jsonSerialize()
  32.     {
  33.         return ['hex' => $this->toHex(true)];
  34.     }
  35.  
  36.     /**
  37.      * Converts an Integer to a hex string (eg. base-16).
  38.      *
  39.      * @return string
  40.      */
  41.     abstract public function toHex();
  42. }
  43.