views:

58

answers:

1

The key issue is if I use a new cryptostream it will add new IV to second piece of data. Then this wont be ablt to decrypted. So I need to make sure the stream will use the last block of 1st data to encrypt the first block of 2nd piece of data.

It comes up with the task of using same stream to encyprt 2 piece of data. But I couldn't figure it out. Tried creating a new class and put all encryption settings inside the class. Then call StreamWriter from the main. But no luck.

Anything I miss or got wrong? Many thanks.

+2  A: 

Instead of letting the AesCryptoServiceProvider generate its own IV, set the IV property explicitly before encrypting the second portion. The value should be the last block of ciphertext from the previous segment.

You shouldn't need to create a new class. Just set the property correctly.

erickson
Thank you for ur postI am pretty new to the field and have no idea how to carry out this.Is it possible to provide some sample code or links?
Kelvin