private function decryptWithPrivateKey($cipher, OpenSslRsaKey $privateKey)
    {
        $decrypted = '';
        $key = openssl_pkey_get_private($privateKey->getKeyString());
        if (openssl_private_decrypt($cipher, $decrypted, $key, $this->paddingAlgorithm) === false) {
            // Fallback for data that was encrypted with old default OPENSSL_PKCS1_PADDING
            if ($this->paddingAlgorithm !== OPENSSL_PKCS1_PADDING) {
                if (openssl_private_decrypt($cipher, $decrypted, $key, OPENSSL_PKCS1_PADDING) !== false) {
                    return $decrypted;
                }
            }
            $openSslErrors = [];
            while (($errorMessage = openssl_error_string()) !== false) {
                $openSslErrors[] = $errorMessage;
            }
            throw new SecurityException(sprintf('Decryption failed, OpenSSL error: %s', implode(chr(10), $openSslErrors)), 1556609762);
        }

        return $decrypted;
    }
private function decryptWithPrivateKey($cipher, OpenSslRsaKey $privateKey)
    {
        $decrypted = '';
        $key = openssl_pkey_get_private($privateKey->getKeyString());
        if (openssl_private_decrypt($cipher, $decrypted, $key, $this->paddingAlgorithm) === false) {
            // Fallback for data that was encrypted with old default OPENSSL_PKCS1_PADDING
            if ($this->paddingAlgorithm !== OPENSSL_PKCS1_PADDING) {
                if (openssl_private_decrypt($cipher, $decrypted, $key, OPENSSL_PKCS1_PADDING) !== false) {
                    return $decrypted;
                }
            }
            $openSslErrors = [];
            while (($errorMessage = openssl_error_string()) !== false) {
                $openSslErrors[] = $errorMessage;
            }
            throw new SecurityException(sprintf('Decryption failed, OpenSSL error: %s', implode(chr(10), $openSslErrors)), 1556609762);
        }

        return $decrypted;
    }
private function decryptWithPrivateKey ( $ cipher , OpenSslRsaKey $ privateKey ) { $ decrypted = '' ; $ key = openssl_pkey_get_private ( $ privateKey -> getKeyString ( ) ) ; if ( openssl_private_decrypt ( $ cipher , $ decrypted , $ key , $ this -> paddingAlgorithm ) === false ) { // Fallback for data that was encrypted with old default OPENSSL_PKCS1_PADDING if ( $ this -> paddingAlgorithm !== OPENSSL_PKCS1_PADDING ) { if ( openssl_private_decrypt ( $ cipher , $ decrypted , $ key , OPENSSL_PKCS1_PADDING ) !== false ) { return $ decrypted ; } } $ openSslErrors = [ ] ; while ( ( $ errorMessage = openssl_error_string ( ) ) !== false ) { $ openSslErrors [ ] = $ errorMessage ; } throw new SecurityException ( sprintf ( 'Decryption failed, OpenSSL error: %s' , implode ( chr ( 10 ) , $ openSslErrors ) ) , 1556609762 ) ; } return $ decrypted ; }
Decrypts the given ciphertext with the given private key

@param string $cipher The ciphertext to decrypt
@param OpenSslRsaKey $privateKey The private key
@return string The decrypted plaintext
@throws SecurityException
Decrypts the given ciphertext with the given private key