title: vb.net AES decryption returns "data is incomplete block"
body: <p>I'm aware of the other thread on this issue (<a href="https://stackoverflow.com/questions/28831084/aes-decryption-error-the-input-data-is-not-a-complete-block-error-vb-net">AES decryption error &quot; The input data is not a complete block.&quot; Error vb.net</a>), but I'm either not implementing the solutions offered there correctly, or something about my particular variant of this issue isn't covered by those solutions. In any event I'm getting the incomplete block error from the following code</p>
  
  <pre><code>Private GD As System.Security.Cryptography.Aes = System.Security.Cryptography.Aes.Create
  Private PDB As New System.Security.Cryptography.Rfc2898DeriveBytes(EK, New Byte() {&amp;H49, &amp;H76, &amp;H61, &amp;H6E, &amp;H20, &amp;H4D, &amp;H65, &amp;H64, &amp;H76, &amp;H65, &amp;H64, &amp;H65, &amp;H76})
  
  Public Function Decrypt(ByVal val As String) As String
      Dim ret As String = Nothing
      Dim TTB As New System.Text.UTF8Encoding
  
      Try
          Dim input() As Byte = TTB.GetBytes(val)
  
          Using ms As New System.IO.MemoryStream(input)
              Using cs As New System.Security.Cryptography.CryptoStream(ms, GD.CreateDecryptor(PDB.GetBytes(32), PDB.GetBytes(16)), Security.Cryptography.CryptoStreamMode.Read)
                  Using sr As New System.IO.StreamReader(cs)
                      ret = sr.ReadToEnd()
                  End Using
              End Using
          End Using
  
          input = nothing
      Catch ex As Exception
          EL.AddErr("Encountered an error while decrypting the provided text for " &amp; FName &amp; ". Error Details: " &amp; ex.Message, path)
      End Try
  
      Return ret
  End Function
  </code></pre>
  
  <p><code>EK</code> is my key, which I'll not be including. It's just a String though, nothing special.</p>
  
  <p>I've tried several other methods to decrypt based on guidance on the MSDN site, DreamInCode, etc. None worked, but they all had different issues (typically returning a blank string). Seeing as this version of code closely mirrors my encryption code, I'd like to stick with it (or at least as close as I can while still having functional code).</p>