title: PHP Steam bot - How to login to page using RSA
body: <p>I've been trying to make simple Steam bot for sending announcements to Steam group by logging in to Steam page and then sending annoucement.
  I got stuck in logging in. Here is what I have:</p>
  
  <pre><code>include('Math/BigInteger.php');    
  include('Crypt/RSA.php');
  $url = 'http://store.steampowered.com/login/getrsakey/';    // here I get public key
  $data = array('username' =&gt; 'user');         // I'm sending username by POST method
  
  $options = array(
      'http' =&gt; array(
          'header'  =&gt; "Content-type: application/x-www-form-urlencoded\r\n",
          'method'  =&gt; 'POST',
          'content' =&gt; http_build_query($data),
      ),
  );
  $context  = stream_context_create($options);
  $result = file_get_contents($url, false, $context);
  $result = json_decode($result)
  
  // And this is part that don't work:
  
  $rsa = new Crypt_RSA();
  $key = array(
      'n' =&gt; new Math_BigInteger($result-&gt;publickey_mod,16),
      'e' =&gt; new Math_BigInteger($result-&gt;publickey_exp,2)
  );
  $rsa-&gt;loadKey($key);
  $password = $rsa-&gt;encrypt("password");    // encrypting password
  $data = array(
      'username' =&gt; 'user',
      'password' =&gt; $password,
      'twofactorcode'=&gt; "",
      'emailauth'=&gt; "", 
      'loginfriendlyname'=&gt; "", 
      'captchagid'=&gt; "", 
      'captcha_text'=&gt; "", 
      'emailsteamid'=&gt; "", 
      'rsatimestamp'=&gt; $result-&gt;timestamp, 
      'remember_login'=&gt; "false" 
  );
  $options = array(
      'http' =&gt; array(
          'header'  =&gt; "Content-type: application/x-www-form-urlencoded\r\n",
          'method'  =&gt; 'POST',
          'content' =&gt; http_build_query($data),
      ),
  );
  $context  = stream_context_create($options);
  $result = file_get_contents($url, false, $context);
  </code></pre>
  
  <p>And result is:</p>
  
  <pre><code>{"success":false}
  </code></pre>
  
  <p>Problem is that encrypted password does not look same as when I encrypted it with javascript functions which are used by Steam.
  So I tried encrypting password in javascript and then just paste it in PHP code but that didn't work either.</p>
  
  <p>Any help would be appreciated.</p>