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