473,402 Members | 2,053 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 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 4098
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Khor Soon Hua | last post by:
when i run the following code, the above error is occured. can anybody help me? sorry cosz it is a vb.net code. Public Function Decrypt(ByVal strToDecrypt As String) As String Dim sb As New...
5
by: weixiang | last post by:
Hi, I want to use DES and CryptoStream to serialize a encrypted stream to a file with a header "CRYPT". And I wrote these code: To store: FileStream fileStream = new FileStream(fileName,...
3
by: James | last post by:
Hi, I am developing a ActiveX Control which will be used in a web page. The control will encrypt some value then decrypt it when the web page opens next time. I tested the control in a windows...
2
by: pesso | last post by:
I have the following code that's taken and modified from a got_dot_net example. I'm trying to decrypt an Xml file that's been encrypted. I can dump the decrypted stream to the console, but if I...
3
by: Bruce Wood | last post by:
Maybe I'm going nuts, but I was so sure that adding the same method more than once to a delegate would result in only one entry on the delegate's call list: this.UpdateEnd += new...
7
by: semedao | last post by:
Hi, I am using cryptostream on both sides on tcp connection that pass data. I am also use asyc socket , so , the data that recieved in the callback method not always have the length of the buffer...
4
by: lakepeir | last post by:
Hello, I have combobox with a selectedindexchanged method that seems to be called when starting the application, launching the form with the combobox and making a change in the drop down box of...
4
by: TarTar | last post by:
Hello, I have already posted this problem, but I have not received any response yet. I will try to describe it again. We have a list control (e.g. DataList) and an ObjectDataSource on an...
9
by: TC | last post by:
Hey All, I posted this to the Crypto users group and forgot to add the VB.Net users group. I apologize for any confusion. I have been testing a try / catch / finally block and purposely...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.