Sorry, I meant to add this, here is the code that generates the error.
bytDataToBeDecrypted = Convert.FromBase64String(vstrStringToBeDecrypted)
bytDecryptionKey = Encoding.ASCII.GetBytes(vstrDecryptionKey.ToCharAr ray)
ReDim bytTemp(bytDataToBeDecrypted.Length)
objMemoryStream = New MemoryStream(bytDataToBeDecrypted)
objCryptoStream = New CryptoStream(objMemoryStream,
objRijndaelManaged.CreateDecryptor(bytDecryptionKe y, bytIV),
CryptoStreamMode.Read)
objCryptoStream.Read(bytTemp, 0, bytTemp.Length)
Try
objCryptoStream.FlushFinalBlock() <-- It goes to the Catch statement from
here
objMemoryStream.Close()
objCryptoStream.Close()
Catch ex As Exception
MsgBox("DecryptString: " & ex.ToString)
End Try
Thanx,
--
Anil Gupte
"Anil Gupte/iCinema.com" <an*******@icinema.comwrote in message
news:ew****************@TK2MSFTNGP04.phx.gbl...
>I am getting the following message and no, it is not even going to that
statement twice. Why is this happening?
System.NotSupportedException was caught
Message="FlushFinalBlock() method was called twice on a CryptoStream. It
can only be called once."
Source="mscorlib"
StackTrace:
at System.Security.Cryptography.CryptoStream.FlushFin alBlock()
at TempCrypt.Crypt.DecryptString128Bit(String
vstrStringToBeDecrypted, String vstrDecryptionKey) in
D:\Projects\VB\TempCrypt\TempCrypt\Crypt.vb:line 132
TIA,
--
Anil Gupte
www.keeninc.net
www.icinema.com
www.wizo.tv