title: SQL and C# Encryption
body: <p>I am using an encryption in C# like this:</p>
  
  <pre><code>// Step 1. We hash the passphrase using MD5
  // We use the MD5 hash generator as the result is a 128 bit byte array
  // which is a valid length for the TripleDES encoder we use below  
  var utf8 = new UTF8Encoding();
  var hashProvider = new MD5CryptoServiceProvider();
  var tdesKey = hashProvider.ComputeHash(utf8.GetBytes(passwordPhrase));
  
  // Step 2. Create a new TripleDESCryptoServiceProvider object
  var tdesAlgorithm = new TripleDESCryptoServiceProvider
                          {
                              Key = tdesKey,
                              Mode = CipherMode.ECB,
                              Padding = PaddingMode.PKCS7
                          };
  
  // Step 3. Attempt to encrypt the string
  var dataToEncrypt = utf8.GetBytes(message);
  var encryptor = tdesAlgorithm.CreateEncryptor();
  
  return Convert.ToBase64String(
      encryptor.TransformFinalBlock(
          dataToEncrypt, 0, dataToEncrypt.Length));
  </code></pre>
  
  <p>I want to use the same process in SQL Server. So I mean that an encrypted message from C# code and encrypted message from SQL Server must be the same string. </p>
  
  <p>For example, <code>683846</code> will become <code>fN8r09iDu4c=</code> in SQL Server too. </p>
  
  <p>How can I do this?</p>