Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top