title: PHP code to encrypt using 3DES algorithm using CBC mode and a secretkey and IV spec key
body: <p>i am try to encrypt following data using the 3des(CBC) using a secretkey and IV spec key in php but i am not getting the same output which i get on this online tool (<a href="http://symmetric-ciphers.online-domain-tools.com/" rel="nofollow">http://symmetric-ciphers.online-domain-tools.com/</a>)</p>
  
  <pre><code>//input
  $data = "Id=120278;timestamp=2009-02-05 08:28:39.195";
  $key = "80127ECD5E40BB25DB14354A3795880DF2B459BB08E1EE6D";
  $iv = "331BA9C5A7446C98";
  
  //output from online tool. I should get the same result in my php code
  $result = "1C80CBCE1713128176499C7A3DFB8779156B31B8DEF2F667A7100F1C3AEFABACB24283CFDF 5D312D A0074897138684BC";
  </code></pre>
  
  <p>following the PHP code i tried</p>
  
  <pre><code>$string = "Id=120278;timestamp=2009-02-05 08:28:39.195";
  $iv = "331BA9C5A7446C98";
  $passphrase = "80127ECD5E40BB25DB14354A3795880DF2B459BB08E1EE6D"; 
  $encryptedString = encryptString($string, $passphrase, $iv);
  
  function encryptString($unencryptedText, $passphrase, $iv) { 
    $enc = mcrypt_encrypt(MCRYPT_3DES, $passphrase, $unencryptedText, MCRYPT_MODE_CBC, $iv); 
    return base64_encode($enc);
  }
  </code></pre>