phpseclib: OpenSSL Interoperability

CLI: PHP Bindings (openssl_*):

Encrypt (PKCS#1) with

openssl rsautl -inkey publickey.txt -pubin -encrypt -in plaintext.txt -out ciphertext.txt

Decrypt with

<?php
include('Crypt/RSA.php');

$rsa = new Crypt_RSA();
$rsa->loadKey(file_get_contents('privatekey.txt'));
$rsa->setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1);
echo $rsa->decrypt(file_get_contents('ciphertext.txt'));