encrypt

J

JW

I can encrypt the contents of a memory stream with no problems, however when
decrypting( I'm using the same key an IV ) I get an exception stating bad
data.

I'm at a lost. I'm actually creating a new memory stream, filling it with
the encrypted bytes then trying to read from the crypto stream object. I
have used the same approach encrypting to a file handle and then decrypting
from the same file and it works.



sample: (this same code works with a file stream but not memory stream) what
am I missing?

MemoryStream memStrEnc2 = new MemoryStream(newByte, 0, newByte.Length);

CryptoStream decStream = new CryptoStream(memStrEnc2,
tdes.CreateDecryptor(random, random), CryptoStreamMode.Read);

byte[] memString2 = new Byte[memStrEnc2.Length];

decStream.Read(memString2, 0, 16);

decStream.Close();



Thank you for your time

Josiah
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top