Re: Simple file encryption decryption problem in C#
- From: rossum <rossum48@xxxxxxxxxxxx>
- Date: Fri, 24 Apr 2009 00:05:43 +0100
On Thu, 23 Apr 2009 22:37:59 +0100, "Andrew Jocelyn"
<j055@xxxxxxxxxxxxxxxx> wrote:
HiYou say that your code works with a FileStream. Display the encrypted
I've created an encrypt and decrypt function, modified from article
http://www.dotnetthis.com/Articles/Crypto.htm. It accepts streams instead of
file paths. The functions work if I send in FileStreams. I can encrypt and
decrypt. If I send in a MemoryStream to it then write the stream to the
website response stream the stream seems to be truncated. It needs to work
with all file types. It breaks even with a short text file.
contents of the FileStream and compare them with the encrypted
contents of the MemoryStream, same password, IV and plaintext of
course. TripleDES is a 64 bit (8 byte) block cypher, so if the
MemoryStream cyphertext is 8 bytes shorter then you are probably not
flushing out the last block properly when encoding. If the decoded
plaintext is shorter then you may not be flushing on decode. Padding
may mean that the difference is not exactly 8 bytes on decoding.
Unless you absolutely have to use TripleDES for backwards
compatibility with old code, you should avoid it because it is now
obsolescent and insecure. Use Rijndael (AES) instead.
Code below. What am I doing wrong?You are posting incomplete and uncompilable code. Post the minimal
code that shows the problem and can be cut and pasted directly into an
IDE and compile first time. Help us to help you.
rossum
[snip code]
Many thanks
Andrew
.
- References:
- Simple file encryption decryption problem in C#
- From: Andrew Jocelyn
- Simple file encryption decryption problem in C#
- Prev by Date: Re: Hitler's Unit Test
- Next by Date: Re: Visual Studio Designer deleting necessary designer code
- Previous by thread: Re: Simple file encryption decryption problem in C#
- Next by thread: RE: Simple file encryption decryption problem in C#
- Index(es):
Relevant Pages
|