title: tripleDES decryption c#
body: <p>I am given a tripleDES encrypted and encoded base 64 string: </p>
  
  <p>ABvAsOKcGXqc5uQ4O5Z53isJaH31Pa8+PeddljE4mSU=</p>
  
  <p>I am also given:</p>
  
  <p>key size = 128;</p>
  
  <p>key = 0123456789ABCDEF</p>
  
  <p>iv = ABCDEFGH</p>
  
  <p>I have written out the following code. I keep on getting an exception thrown at me saying "Bad PKCS7 padding. Invalid length 31" I am losing a byte somewhere I think. Can anyone please tell me what I am doing wrong.</p>
  
  <pre><code>string base64Encoded = "ABvAsOKcGXqc5uQ4O5Z53isJaH31Pa8+PeddljE4mSU="; // 
  string ASCIIkey = "0123456789ABCDEF";
  string ASCIIiv = "ABCDEFGH";
  
  
  TripleDESCryptoServiceProvider tDES = new TripleDESCryptoServiceProvider();
  tDES.KeySize = 128;
  tDES.BlockSize = 64;
  tDES.Padding = PaddingMode.PKCS7;
  tDES.Mode = CipherMode.ECB;
  tDES.Key = Encoding.ASCII.GetBytes(ASCIIkey);
  tDES.IV = Encoding.ASCII.GetBytes (ASCIIiv);
  byte[] encryptedData = Convert.FromBase64String(base64Encoded);
  ICryptoTransform transform = tDES.CreateDecryptor();
  byte[] plainText = transform.TransformFinalBlock(encryptedData, 0, encryptedData.Length);
  string message = System.Text.Encoding.ASCII.GetString(plainText);
  Console.Write (message);
  </code></pre>