public function encryptWithPublicKey($plaintext, $fingerprint)
    {
        $cipher = '';
        if (openssl_public_encrypt($plaintext, $cipher, $this->getPublicKey($fingerprint)->getKeyString(), $this->paddingAlgorithm) === false) {
            $openSslErrors = [];
            while (($errorMessage = openssl_error_string()) !== false) {
                $openSslErrors[] = $errorMessage;
            }
            throw new SecurityException(sprintf('Encryption failed, OpenSSL error: %s', implode(chr(10), $openSslErrors)), 1556609369);
        }

        return $cipher;
    }
public function encryptWithPublicKey($plaintext, $fingerprint)
    {
        $cipher = '';
        if (openssl_public_encrypt($plaintext, $cipher, $this->getPublicKey($fingerprint)->getKeyString(), $this->paddingAlgorithm) === false) {
            $openSslErrors = [];
            while (($errorMessage = openssl_error_string()) !== false) {
                $openSslErrors[] = $errorMessage;
            }
            throw new SecurityException(sprintf('Encryption failed, OpenSSL error: %s', implode(chr(10), $openSslErrors)), 1556609369);
        }

        return $cipher;
    }
public function encryptWithPublicKey ( $ plaintext , $ fingerprint ) { $ cipher = '' ; if ( openssl_public_encrypt ( $ plaintext , $ cipher , $ this -> getPublicKey ( $ fingerprint ) -> getKeyString ( ) , $ this -> paddingAlgorithm ) === false ) { $ openSslErrors = [ ] ; while ( ( $ errorMessage = openssl_error_string ( ) ) !== false ) { $ openSslErrors [ ] = $ errorMessage ; } throw new SecurityException ( sprintf ( 'Encryption failed, OpenSSL error: %s' , implode ( chr ( 10 ) , $ openSslErrors ) ) , 1556609369 ) ; } return $ cipher ; }
Encrypts the given plaintext with the public key identified by the given fingerprint

@param string $plaintext The plaintext to encrypt
@param string $fingerprint The fingerprint to identify to correct public key
@return string The ciphertext
@throws SecurityException If encryption failed for some other reason
Encrypts the given plaintext with the public key identified by the given fingerprint