title: Sagepay upgrade from 2.33 to 3.00 AES & response form
body: <p>I'm a junior dev (new on the job) being tasked with carrying out an upgrade from Sagepay 2.23 --> 3.00. (on a site we've recently taken over) I've made the change to VPSProtocol and I think i've successfully implemented a move to AES.</p>
  
  <p>However, the previous chunk of code was set to:</p>
  
  <pre><code>$strCrypt = base64Encode(SimpleXor($strPost,$strEncryptionPassword));
  </code></pre>
  
  <p>I intend to comment that out and have popped this in:</p>
  
  <pre><code>function pkcs5_pad($text, $blocksize)
  {
      $pad = $blocksize - (strlen($text) % $blocksize);
      //echo "&lt;br/&gt;Padding:".str_repeat(chr($pad), $pad)."&lt;";
      return $text . str_repeat(chr($pad), $pad);
  }
  
  function encryptFieldData($input)
  {
      $key = $strEncryptionPassword;
      $iv = $key;
  
      $cipher = mcrypt_module_open(MCRYPT_RIJNDAEL_128, "", MCRYPT_MODE_CBC, "");
      if (mcrypt_generic_init($cipher, $key, $iv) != -1)
      {
          $cipherText = mcrypt_generic($cipher,$input );
          mcrypt_generic_deinit($cipher);
  
          $enc = bin2hex($cipherText);
      }
      return $enc;
  }
  
  $datapadded = pkcs5_pad($str,16);
  $cryptpadded = "@" . encryptFieldData($datapadded);
  </code></pre>
  
  <p>And made the change here:</p>
  
  <pre><code>&lt;input type="hidden" name="Crypt" value="&lt;? echo $cryptpadded ?&gt;"&gt; 
  </code></pre>
  
  <p>I think that's enough, i'm awaiting access to the Sagepay test environment.</p>
  
  <p>In terms of the Response Field, I don't fully understand where to implement the required changes. The sample code provided lists this information, but the existing php file does not appear to include any data for a response field.</p>
  
  <p>Any help or guidance would be very much appreciated.
  thanks!</p>