[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/vendor/phpseclib/phpseclib/phpseclib/Crypt/DH/ -> PublicKey.php (source)

   1  <?php
   2  
   3  /**
   4   * DH Public Key
   5   *
   6   * @author    Jim Wigginton <terrafrost@php.net>
   7   * @copyright 2015 Jim Wigginton
   8   * @license   http://www.opensource.org/licenses/mit-license.html  MIT License
   9   * @link      http://phpseclib.sourceforge.net
  10   */
  11  
  12  namespace phpseclib3\Crypt\DH;
  13  
  14  use phpseclib3\Crypt\Common;
  15  use phpseclib3\Crypt\DH;
  16  
  17  /**
  18   * DH Public Key
  19   *
  20   * @author  Jim Wigginton <terrafrost@php.net>
  21   */
  22  final class PublicKey extends DH
  23  {
  24      use Common\Traits\Fingerprint;
  25  
  26      /**
  27       * Returns the public key
  28       *
  29       * @param string $type
  30       * @param array $options optional
  31       * @return string
  32       */
  33      public function toString($type, array $options = [])
  34      {
  35          $type = self::validatePlugin('Keys', $type, 'savePublicKey');
  36  
  37          return $type::savePublicKey($this->prime, $this->base, $this->publicKey, $options);
  38      }
  39  
  40      /**
  41       * Returns the public key as a BigInteger
  42       *
  43       * @return \phpseclib3\Math\BigInteger
  44       */
  45      public function toBigInteger()
  46      {
  47          return $this->publicKey;
  48      }
  49  }