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