471,078 Members | 830 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,078 software developers and data experts.

FlushFinalBlock() method was called twice on a CryptoStream

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
Jun 27 '08 #1
2 3829
On 2008-06-24, Anil Gupte/iCinema.com <an*******@icinema.comwrote:
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,
Well, we would need to see the snippit of code that generates the error to be
sure.

--
Tom Shelton
Jun 27 '08 #2
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

Jun 27 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by weixiang | last post: by
2 posts views Thread by pesso | last post: by
3 posts views Thread by Bruce Wood | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.