title: C# TripleDesCrypto gives different results than VB TripleDesCrypto
body: <p>Trying to use TripleDesCrypto encoding for a project and I keep getting a Bad Data error on decoding.    This is what I had in VB.net </p>
  
  <pre><code>Public Shared Function encode(message As String) As String
      Dim _Key As Byte() = ASCIIEncoding.ASCII.GetBytes("asdf1325asdfs123")
      Dim _IV As Byte() = ASCIIEncoding.ASCII.GetBytes("123ads12")
      Dim sOutput As String = ""
      Try
  
          Dim tdes As TripleDESCryptoServiceProvider = New TripleDESCryptoServiceProvider()
          Dim InputBuffer As Byte() = Encoding.UTF8.GetBytes(message)
          Dim ms As New MemoryStream()
          Dim encStream As New CryptoStream(ms, tdes.CreateEncryptor(_Key, _IV), CryptoStreamMode.Write)
          encStream.Write(InputBuffer, 0, InputBuffer.Length)
          sOutput = Convert.ToBase64String(ms.ToArray())
          encStream.Close()
          ms.Close()
      Catch ex As Exception
          Throw New ArgumentException("Couldn't Encode Message: " + ex.Message)
      End Try
      Return sOutput
  End Function
  </code></pre>
  
  <p>which returns</p>
  
  <pre><code>Cui4ahedjTI=
  </code></pre>
  
  <p>So I tried the same thing in C#.net with this </p>
  
  <pre><code>    public string encode(string message)
      {
          byte[] _Key  = ASCIIEncoding.ASCII.GetBytes("asdf1325asdfs123");
          byte[] _IV = ASCIIEncoding.ASCII.GetBytes("123ads12");
          string sOutput = "";
          try
          {
              TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider();
              byte[] InputBuffer = Encoding.UTF8.GetBytes(message);
              MemoryStream ms = new MemoryStream();
              CryptoStream encStream = new CryptoStream(ms, tdes.CreateEncryptor(_Key, _IV), CryptoStreamMode.Write);
              encStream.Write(InputBuffer, 0, InputBuffer.Length);
              encStream.FlushFinalBlock();
              sOutput = Convert.ToBase64String(ms.ToArray());
              encStream.Close();
              ms.Close();
          }
          catch (Exception ex)
          {
              throw new ArgumentException("couldn't encode message: " + ex.Message);
          }
  
          return sOutput;
      }
  </code></pre>
  
  <p>which returns </p>
  
  <pre><code>ac6EeiwfAQHk26AhfAfaHA==
  </code></pre>
  
  <p>The decoding is occurs in a third party app which I'm assuming is written in C# </p>
  
  <p>Question is why are the results different and is there some way to make the vb.net code return the same result as the C# code? </p>