title: TripleDes decryption with some invalid data at the beginning
body: <p>I am trying to decrypt data using tripleDes. Everything looks fine but it has some invalid characters at the beginning? What am I doing wrong? For same data if call this function again and again these first few characters are always different but the rest of the data is same.</p>
  
  <p>I am passing useHashing to false.</p>
  
  <pre><code>public static byte[] GetTripleDesDecryption(string dataToDecrypt, byte[] key, bool useHashing)
      {
          byte[] keyArray;
          byte[] plainbytes = null;
          byte[] cipherbytes;
  
          try
          {
              if (useHashing)
              {
                  MD5CryptoServiceProvider hashmd5 = new MD5CryptoServiceProvider();
                  keyArray = hashmd5.ComputeHash(key);
                  hashmd5.Clear();
              }
              else
                  keyArray = key;
  
              using (TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider())
              {
                  tdes.Key = keyArray;
                  tdes.Mode = CipherMode.CBC;
                  tdes.Padding = PaddingMode.None;
  
                  using (ICryptoTransform cTransform = tdes.CreateDecryptor())
                  {
                      cipherbytes = Convert.FromBase64String(dataToDecrypt);
                      plainbytes = cTransform.TransformFinalBlock(cipherbytes, 0, cipherbytes.Length);
                  }
              }
          }
          catch (Exception e)
          {
              LogMessage(e.Message + " Attribute Parsing error. DataToDecrypt = " + dataToDecrypt);
              throw e;
          }
          return plainbytes;
      }
  </code></pre>
  
  <p>This is what I get:</p>
  
  <pre><code>"�{c��]�sertion xmlns:saml=\"urn:oasis:names:tc:SAML:2.0:assertion\"&gt;&lt;saml:AttributeStatement&gt;&lt;saml:Attribute Name=\"userID\"&gt;&lt;saml:AttributeValue&gt;456&lt;/saml:AttributeValue&gt;&lt;/saml:Attribute&gt;&lt;saml:Attribute Name=\"financialInstitutionNumber\"&gt;&lt;saml:AttributeValue&gt;303986258&lt;/saml:AttributeValue&gt;&lt;/saml:Attribute&gt;&lt;saml:Attribute Name=\"password\"&gt;&lt;saml:AttributeValue&gt;galaxy&lt;/saml:AttributeValue&gt;&lt;/saml:Attribute&gt;&lt;/saml:AttributeStatement&gt;&lt;/saml:Assertion&gt;   "
  </code></pre>