title: How to decrypt a triple DES string in PHP page?
body: <p>I was hoping someone could help a non-PHP developer with an example of how to decrypt a Triple DES URL Encoded string (e.g. passed to the page in a querystring variable named "q").</p>
  
  <p>The key is 24 bit and the intialization vector is 8 bit.</p>
  
  <p>In C# the original data is:</p>
  
  <ol>
  <li>UTF-8 encoded as a byte array </li>
  <li>Encrypted with the key and IV</li>
  <li>Encoded as a Base 64 string</li>
  <li>URL encoded as a string</li>
  </ol>
  
  <p>...</p>
  
  <pre><code>byte[] rawData;
  TripleDES tripleDESalg = TripleDES.Create();
  rawData = UTF8Encoding.UTF8.GetBytes(message);
  ICryptoTransform cTransform = tripleDESalg.CreateEncryptor(key, IV);
  byte[] resultArray = cTransform.TransformFinalBlock(rawData, 0, rawData.Length);
  tripleDESalg.Clear();
  encryptedText = Convert.ToBase64String(resultArray);
  </code></pre>
  
  <p>...</p>
  
  <p>In a PHP page, I can't really find examples on how to these steps together:</p>
  
  <ol>
  <li>Decode the URL encoded string in the querystring variable "q"</li>
  <li>Decode the Base 64 encoded string (e.g. base64_decode)</li>
  <li>Decrypt the value using the same key and iv that was used to encrypt it (assume you control the encrypting and decrypting and both system know what the key and iv are)</li>
  <li>Print/echo the output</li>
  </ol>
  
  <p>