C#'s opposite to PHP's bin2hex()
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/311165/how-do-you-convert-byte-array-to-hexadecimal-string-and-vice-versa-in-c">How do you convert Byte Array to Hexadecimal String, and vice versa, in C#?</a><br>
  <a href="http://stackoverflow.com/questions/321370/convert-hex-string-to-byte-array">Convert hex string to byte array</a>  </p>
</blockquote>



<p>I am encrypting a string in PHP and I would like to decrypt this string using C#. The last line of the encryption function will return a hexadecimal representation of the encrypted string. Unfortunately for me, though, I cannot figure out how to reverse this conversion through C#. I will post my source below:</p>

<h3> PHP: </h3>

<pre><code>echo encrypt('hello'); // Returns '60eb44e27e73ba1d'
function encrypt($string) {
        //Key
        $key = "12345678";

        //Encryption
        $cipher_alg = MCRYPT_TRIPLEDES;

        $iv = mcrypt_create_iv(mcrypt_get_iv_size($cipher_alg,MCRYPT_MODE_ECB), MCRYPT_RAND); 

        $encrypted_string = mcrypt_encrypt($cipher_alg, $key, $string, MCRYPT_MODE_ECB, $iv);
        return bin2hex($encrypted_string);
    }
</code></pre>

<p>The only issue I am having is the hex2bin conversion in C# - the rest of the decryption function I have working. Feel free to ask for any further details.</p>

<p>Hopefully there is some simple solution out there that I don't know about. I appreciate any responses.</p>

<p>Regards,</p>

<p>Evan</p>
