By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,919 Members | 1,587 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,919 IT Pros & Developers. It's quick & easy.

Encryption issue

P: n/a
Hi,

I am trying to encrypt and decrypt an XML string. I have it encrypting
but decrypting is a problem, somehow the XML is getting all corrupted.

Any ideas?

Im saving the XML text to a byte[] and then encrypting that using DES, and
writing it to a file and the reverse for reading it back in.

Thanks
Jul 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Can you post an example, and a little more detail about what is going
wrong?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<di********@discussion.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi,

I am trying to encrypt and decrypt an XML string. I have it encrypting
but decrypting is a problem, somehow the XML is getting all corrupted.

Any ideas?

Im saving the XML text to a byte[] and then encrypting that using DES, and writing it to a file and the reverse for reading it back in.

Thanks

Jul 21 '05 #2

P: n/a
I got it working, instead of storing as a binary file directly and using the
default CipherMode i now store as a base64string and use ECB so its the same
for the same keyusage.

I do get exceptions on keylenghts when i compute the MD5 hash on the key,
the key is 8 bytes as an example and hashed to 16 bytes.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:ez**************@TK2MSFTNGP12.phx.gbl...
Can you post an example, and a little more detail about what is going
wrong?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<di********@discussion.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi,

I am trying to encrypt and decrypt an XML string. I have it encrypting but decrypting is a problem, somehow the XML is getting all corrupted.

Any ideas?

Im saving the XML text to a byte[] and then encrypting that using DES,

and
writing it to a file and the reverse for reading it back in.

Thanks


Jul 21 '05 #3

P: n/a

<di********@discussion.microsoft.com> wrote in message
news:up****************@TK2MSFTNGP10.phx.gbl...
I got it working, instead of storing as a binary file directly and using the default CipherMode i now store as a base64string and use ECB so its the same for the same keyusage.
I would recommend using CBC mode. ECB mode is more susceptible to
cryptanalysis. Feedback modes help obscure common patterns in the data.
Also, you might want to consider using an algorithm with a larger key. DES
is old-school encryption, has a weak key size, and is being replaced with
AES (which is basically the Rijndael algorithm for the block cipher part of
the spec).
Saving the XML to a common encoding (base64) probably fixed your real issue,
so again, consider going back to CBC mode. In addition, there may yet be a
descrepency between your encrypt/decrypt functions. It's hard to tell unless
you post the code.
I do get exceptions on keylenghts when i compute the MD5 hash on the key,
the key is 8 bytes as an example and hashed to 16 bytes.


Hashes always compute a fixed-length result reguardless of how much data you
feed them as input. MD5 always results in 16 bytes even if the input is
bigger or smaller.

-Rob Teixeira [MVP]
Jul 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.