public function extractPublicKey($private, $passphrase = null)
    {
        $this->clearBufferedMessages();

        if (false === ($resource = openssl_pkey_get_private($private, $passphrase))) {
            throw new RuntimeException(sprintf(
                'The private key could not be processed: %s',
                openssl_error_string()
            ));
        }

        if (false === ($details = openssl_pkey_get_details($resource))) {
            throw new RuntimeException(sprintf(
                'The details of the private key could not be extracted: %s',
                openssl_error_string()
            ));
        }

        openssl_free_key($resource);

        return $details['key'];
    }
public function extractPublicKey($private, $passphrase = null)
    {
        $this->clearBufferedMessages();

        if (false === ($resource = openssl_pkey_get_private($private, $passphrase))) {
            throw new RuntimeException(sprintf(
                'The private key could not be processed: %s',
                openssl_error_string()
            ));
        }

        if (false === ($details = openssl_pkey_get_details($resource))) {
            throw new RuntimeException(sprintf(
                'The details of the private key could not be extracted: %s',
                openssl_error_string()
            ));
        }

        openssl_free_key($resource);

        return $details['key'];
    }
public function extractPublicKey ( $ private , $ passphrase = null ) { $ this -> clearBufferedMessages ( ) ; if ( false === ( $ resource = openssl_pkey_get_private ( $ private , $ passphrase ) ) ) { throw new RuntimeException ( sprintf ( 'The private key could not be processed: %s' , openssl_error_string ( ) ) ) ; } if ( false === ( $ details = openssl_pkey_get_details ( $ resource ) ) ) { throw new RuntimeException ( sprintf ( 'The details of the private key could not be extracted: %s' , openssl_error_string ( ) ) ) ; } openssl_free_key ( $ resource ) ; return $ details [ 'key' ] ; }
Extracts the public key from the private key.

@param string      $private    The private key.
@param null|string $passphrase The passphrase.

@return string The public key.

@throws RuntimeException If the public key could not be extracted.

@api
Extracts the public key from the private key .