phpseclib\Crypt\RSA\PKCS1::savePublicKey PHP Method

savePublicKey() static public method

Convert a public key to the appropriate format
static public savePublicKey ( phpseclib\Math\BigInteger $n, phpseclib\Math\BigInteger $e ) : string
$n phpseclib\Math\BigInteger
$e phpseclib\Math\BigInteger
return string
    static function savePublicKey(BigInteger $n, BigInteger $e)
    {
        $key = ['modulus' => $n, 'publicExponent' => $e];
        $asn1 = new ASN1();
        $key = $asn1->encodeDER($key, RSAPublicKey);
        return self::wrapPublicKey($key, 'RSA');
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * Convert a public key to the appropriate format
  *
  * @access public
  * @param \phpseclib\Math\BigInteger $n
  * @param \phpseclib\Math\BigInteger $e
  * @return string
  */
 static function savePublicKey(BigInteger $n, BigInteger $e)
 {
     $key = PKCS1::savePublicKey($n, $e);
     $key = ASN1::extractBER($key);
     return self::wrapPublicKey($key, '1.2.840.113549.1.1.1');
 }