473,797 Members | 3,079 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.NotSuppo rtedException was caught
Message="FlushF inalBlock() method was called twice on a CryptoStream. It
can only be called once."
Source="mscorli b"
StackTrace:
at System.Security .Cryptography.C ryptoStream.Flu shFinalBlock()
at TempCrypt.Crypt .DecryptString1 28Bit(String
vstrStringToBeD ecrypted, String vstrDecryptionK ey) in
D:\Projects\VB\ TempCrypt\TempC rypt\Crypt.vb:l ine 132

TIA,
--
Anil Gupte
www.keeninc.net
www.icinema.com
www.wizo.tv
Jun 27 '08 #1
2 4134
On 2008-06-24, Anil Gupte/iCinema.com <an*******@icin ema.comwrote:
I am getting the following message and no, it is not even going to that
statement twice. Why is this happening?
System.NotSuppo rtedException was caught
Message="FlushF inalBlock() method was called twice on a CryptoStream. It
can only be called once."
Source="mscorli b"
StackTrace:
at System.Security .Cryptography.C ryptoStream.Flu shFinalBlock()
at TempCrypt.Crypt .DecryptString1 28Bit(String
vstrStringToBeD ecrypted, String vstrDecryptionK ey) in
D:\Projects\VB\ TempCrypt\TempC rypt\Crypt.vb:l ine 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.

bytDataToBeDecr ypted = Convert.FromBas e64String(vstrS tringToBeDecryp ted)
bytDecryptionKe y = Encoding.ASCII. GetBytes(vstrDe cryptionKey.ToC harArray)
ReDim bytTemp(bytData ToBeDecrypted.L ength)
objMemoryStream = New MemoryStream(by tDataToBeDecryp ted)
objCryptoStream = New CryptoStream(ob jMemoryStream,
objRijndaelMana ged.CreateDecry ptor(bytDecrypt ionKey, bytIV),
CryptoStreamMod e.Read)
objCryptoStream .Read(bytTemp, 0, bytTemp.Length)
Try
objCryptoStream .FlushFinalBloc k() <-- It goes to the Catch statement from
here
objMemoryStream .Close()
objCryptoStream .Close()
Catch ex As Exception
MsgBox("Decrypt String: " & ex.ToString)
End Try

Thanx,
--
Anil Gupte

"Anil Gupte/iCinema.com" <an*******@icin ema.comwrote in message
news:ew******** ********@TK2MSF TNGP04.phx.gbl. ..
>I am getting the following message and no, it is not even going to that
statement twice. Why is this happening?
System.NotSuppo rtedException was caught
Message="FlushF inalBlock() method was called twice on a CryptoStream. It
can only be called once."
Source="mscorli b"
StackTrace:
at System.Security .Cryptography.C ryptoStream.Flu shFinalBlock()
at TempCrypt.Crypt .DecryptString1 28Bit(String
vstrStringToBeD ecrypted, String vstrDecryptionK ey) in
D:\Projects\VB\ TempCrypt\TempC rypt\Crypt.vb:l ine 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
2766
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 StringBuilder Dim byteToDecrypt() As Byte = Convert.FromBase64String(strToDecrypt) Dim byteDecoded(byteToDecrypt.Length) As Byte Dim ms As New MemoryStream(byteToDecrypt) Dim cs As CryptoStream
5
12927
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, FileMode.Create, FileAccess.Write, FileShare.None); byte signture = AE.GetBytes("CRYPT");
3
14017
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 application and it works fine and no error jumps. However, when I tried to use it in a web page, problems came. There is no problem for encrypting but the decrypting can't be finished. The error jumped from the line below
2
4089
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 try to load that into XmlTextReader, it throws XmlException. I'd appreciate your help. //create file stream to read encrypted file back FileStream fsread = new FileStream(args, FileMode.Open, FileAccess.Read);
3
8783
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 EventHandler(UpdateStockCode); this.UpdateEnd += new EventHandler(UpdateStockCode); if (this.UpdateEnd != null) { this.UpdateEnd(this, System.EventArgs.Empty);
7
13382
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 I sent. for ex I want to send 10000 bytes I can get it in 10 times of 1000 bytes each. so , I need to know when I complete the receiving , I want to write inside cryptostream and check the position compare it to the length I already know I...
4
5257
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 the combobox. Can anyone tell me why the method is called so often? I would only like the method executed when a user makes a change in the drop down box. Am I using the incorrect method. Thanks.
4
4705
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 ASP.NET web page. When we open the page the Select method (here: GetCustomers) is called twice. Why? It is obvious performance hit as the data needs to be retrieved twice. How to avoid the duplicated calls?
9
1958
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 raising exceptions and I've noticed that if an exception of "Length of the data to decrypt is invalid." is raised with the CryptoStream object, later this exception will get raised a second time and thrown to the caller when trying to close the stream...
0
9685
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10468
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10205
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9063
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7559
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5458
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5582
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3748
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2933
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.