I am trying to decrypt some texts and getting this error. I did google a lot and read articles. There are a lot of people with the same error but I can't solve mine.
Below is some code sample and you can see the IV that I am using.
The IV is produced by AS3crypto. you can see the demo in this page. you can see on Secret Key tab. My setting is AES, CBC.
i.e. I can't change the IV and i think that IV is a valid one.
I think the problem is the way I am setting IV in .Net which isn't right.
Any thoughts guys?
Thanks in advance.
Using aesAlg As New AesCryptoServiceProvider
Dim IV_COMPONENT As Byte() = Convert.FromBase64String("a462114bca101105db976158381a4d05")
//Dim IV_COMPONENT As Byte() = Encoding.ASCII.GetBytes("a462114bca101105db976158381a4d05")
aesAlg.IV = IV_COMPONENT
aesAlg.Mode = CipherMode.CBC
' Create a decrytor to perform the stream transform.
Dim decryptor As ICryptoTransform = aesAlg.CreateDecryptor(aesAlg.Key, aesAlg.IV)
Using msDecrypt As New MemoryStream(cipherText)
Using csDecrypt As New CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read)
Using srDecrypt As New StreamReader(csDecrypt)
plaintext = srDecrypt.ReadToEnd()
End Using
End Using
End Using
End Using