Subversion Repositories oidplus

Rev

Rev 846 | Rev 1042 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
827 daniel-mar 1
<?php
2
 
3
/**
4
 * Finite Field Integer Base Class
5
 *
6
 * PHP version 5 and 7
7
 *
874 daniel-mar 8
 * @category  Math
9
 * @package   BigInteger
827 daniel-mar 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
 
15
namespace phpseclib3\Math\Common\FiniteField;
16
 
17
/**
18
 * Finite Field Integer
19
 *
874 daniel-mar 20
 * @package Math
827 daniel-mar 21
 * @author  Jim Wigginton <terrafrost@php.net>
874 daniel-mar 22
 * @access  public
827 daniel-mar 23
 */
24
abstract 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
}