title: Unable to use phpseclib classes
body: <p>I've installed the <a href="https://github.com/phpseclib/phpseclib" rel="nofollow">phpseclib</a> library from github and I'm trying to encrypt a password (for steamcommunity) with PHP. I am able to do it with Javascript by using the javascript code Steam has on their website but I cannot encrypt the password using pure PHP.</p>
  
  <p>The Javascript encryption code:</p>
  
  <pre><code>var RSAPublicKey = function($modulus_hex, $encryptionExponent_hex) {
      this.modulus = new BigInteger( $modulus_hex, 16);
      this.encryptionExponent = new BigInteger( $encryptionExponent_hex, 16);
  };
  
  var Base64 = {
      base64: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
      encode: function($input) {
          if (!$input) {
              return false;
          }
          var $output = "";
          var $chr1, $chr2, $chr3;
          var $enc1, $enc2, $enc3, $enc4;
          var $i = 0;
          do {
              $chr1 = $input.charCodeAt($i++);
              $chr2 = $input.charCodeAt($i++);
              $chr3 = $input.charCodeAt($i++);
              $enc1 = $chr1 &gt;&gt; 2;
              $enc2 = (($chr1 &amp; 3) &lt;&lt; 4) | ($chr2 &gt;&gt; 4);
              $enc3 = (($chr2 &amp; 15) &lt;&lt; 2) | ($chr3 &gt;&gt; 6);
              $enc4 = $chr3 &amp; 63;
              if (isNaN($chr2)) $enc3 = $enc4 = 64;
              else if (isNaN($chr3)) $enc4 = 64;
              $output += this.base64.charAt($enc1) + this.base64.charAt($enc2) + this.base64.charAt($enc3) + this.base64.charAt($enc4);
          } while ($i &lt; $input.length);
          return $output;
      },
      decode: function($input) {
          if(!$input) return false;
          $input = $input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
          var $output = "";
          var $enc1, $enc2, $enc3, $enc4;
          var $i = 0;
          do {
              $enc1 = this.base64.indexOf($input.charAt($i++));
              $enc2 = this.base64.indexOf($input.charAt($i++));
              $enc3 = this.base64.indexOf($input.charAt($i++));
              $enc4 = this.base64.indexOf($input.charAt($i++));
              $output += String.fromCharCode(($enc1 &lt;&lt; 2) | ($enc2 &gt;&gt; 4));
              if ($enc3 != 64) $output += String.fromCharCode((($enc2 &amp; 15) &lt;&lt; 4) | ($enc3 &gt;&gt; 2));
              if ($enc4 != 64) $output += String.fromCharCode((($enc3 &amp; 3) &lt;&lt; 6) | $enc4);
          } while ($i &lt; $input.length);
          return $output;
      }
  };
  
  var Hex = {
      hex: "0123456789abcdef",
      encode: function($input) {
          if(!$input) return false;
          var $output = "";
          var $k;
          var $i = 0;
          do {
              $k = $input.charCodeAt($i++);
              $output += this.hex.charAt(($k &gt;&gt; 4) &amp;0xf) + this.hex.charAt($k &amp; 0xf);
          } while ($i &lt; $input.length);
          return $output;
      },
      decode: function($input) {
          if(!$input) return false;
          $input = $input.replace(/[^0-9abcdef]/g, "");
          var $output = "";
          var $i = 0;
          do {
              $output += String.fromCharCode(((this.hex.indexOf($input.charAt($i++)) &lt;&lt; 4) &amp; 0xf0) | (this.hex.indexOf($input.charAt($i++)) &amp; 0xf));
          } while ($i &lt; $input.length);
          return $output;
      }
  };
  
  var RSA = {
  
      getPublicKey: function( $modulus_hex, $exponent_hex ) {
          return new RSAPublicKey( $modulus_hex, $exponent_hex );
      },
  
      encrypt: function($data, $pubkey) {
          if (!$pubkey) return false;
          $data = this.pkcs1pad2($data,($pubkey.modulus.bitLength()+7)&gt;&gt;3);
          if(!$data) return false;
          $data = $data.modPowInt($pubkey.encryptionExponent, $pubkey.modulus);
          if(!$data) return false;
          $data = $data.toString(16);
          if(($data.length &amp; 1) == 1)
              $data = "0" + $data;
          return Base64.encode(Hex.decode($data));
      },
  
      pkcs1pad2: function($data, $keysize) {
          if($keysize &lt; $data.length + 11)
              return null;
          var $buffer = [];
          var $i = $data.length - 1;
          while($i &gt;= 0 &amp;&amp; $keysize &gt; 0)
              $buffer[--$keysize] = $data.charCodeAt($i--);
          $buffer[--$keysize] = 0;
          while($keysize &gt; 2)
              $buffer[--$keysize] = Math.floor(Math.random()*254) + 1;
          $buffer[--$keysize] = 2;
          $buffer[--$keysize] = 0;
          return new BigInteger($buffer);
      }
  };
  </code></pre>
  
  <p>And to encrypt it I simply call the following:</p>
  
  <pre><code>var pubKey = RSA.getPublicKey('&lt;?php echo $curl-&gt;response-&gt;publickey_mod; ?&gt;', '&lt;?php echo $curl-&gt;response-&gt;publickey_exp; ?&gt;');
  var encrypted_password = RSA.encrypt('&lt;?php echo $inviter['password']; ?&gt;', pubKey);
  </code></pre>
  
  <p>When I try to include a file from the phpseclib and use the class, the file includes successfully but the class displays an error saying it's not a valid class.</p>
  
  <p>My PHP code:</p>
  
  <pre><code>&lt;?php
  // publickey_mod = C2242A41A84E56D9CD7952CCB985343A6DCE26AF7CA31036415B7B9DA190DF68BBEC93ED6A9AAE5CA9D6EB1A65244E0013DB38C9462076F8165EDB2A1ECB383A75FB0C71388AFD2C2DC15F9088BA252B4ED2F2C304F545C3704B6B7F5CEE01AF7DD0DC9038CBFBDE7B99689006C5272EBCEC221DB3D9CEB8514E246A571E49709AD94442A8611BE131E6F3FFA40AD632BBD6C5B5F85F7A5C87310E17632145A57BDF17A4F7305E959B4A6126AA8C64C794975F17051E6EAF5462F1189AAD0E7B5F2F254AEEB030D8ED8BAD0F8BD753482E652FFB2405D8947994E143032D5511AF63977A51C9013B5516FA51C5AC50E56588C09C761A473E8D18566B1D435687
  
  // publickey_exp = 010001
  
  require_once 'phpseclib/Crypt/RSA.php';
  require_once 'phpseclib/Crypt/RSA/PKCS1.php';
  
  $pkcs = new \phpseclib\Crypt\RSA\PKCS1();
  
  $key = $pkcs-&gt;savePublicKey(new \phpseclib\Math\BigInteger(C2242A41A84E56D9CD7952CCB985343A6DCE26AF7CA31036415B7B9DA190DF68BBEC93ED6A9AAE5CA9D6EB1A65244E0013DB38C9462076F8165EDB2A1ECB383A75FB0C71388AFD2C2DC15F9088BA252B4ED2F2C304F545C3704B6B7F5CEE01AF7DD0DC9038CBFBDE7B99689006C5272EBCEC221DB3D9CEB8514E246A571E49709AD94442A8611BE131E6F3FFA40AD632BBD6C5B5F85F7A5C87310E17632145A57BDF17A4F7305E959B4A6126AA8C64C794975F17051E6EAF5462F1189AAD0E7B5F2F254AEEB030D8ED8BAD0F8BD753482E652FFB2405D8947994E143032D5511AF63977A51C9013B5516FA51C5AC50E56588C09C761A473E8D18566B1D435687, 16), new \phpseclib\Math\BigInteger(010001, 16));
  
  $rsa = new phpseclib\Crypt\RSA();
  
  $rsa-&gt;setPrivateKeyFormat(CRYPT_RSA_PRIVATE_FORMAT_PKCS1);
  $rsa-&gt;setPublicKeyFormat(CRYPT_RSA_PUBLIC_FORMAT_PKCS1);
  
  $rsa-&gt;setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1);
  define('CRYPT_RSA_PKCS15_COMPAT', true);
  $rsa-&gt;loadKey($key);
  
  $password = $rsa-&gt;encrypt("mySteamPassword");    // encrypting password
  
  var_dump($password);
  
  ?&gt;
  </code></pre>
  
  <p>And the error message that this code displays:</p>
  
  <pre><code>Fatal error: Class 'phpseclib\Crypt\RSA\PKCS' not found in C:\xampp\htdocs\RSA-Encryption\phpseclib\Crypt\RSA\PKCS1.php on line 40
  </code></pre>