473,386 Members | 1,817 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Encryption issue

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
3 1127
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
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

<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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Chris | last post by:
Hello all. I'm currently working on a new site that encompasses the registration of members. The registration is taking place through PHP interaction with MySQL. The site is just going to be...
34
by: Blake T. Garretson | last post by:
I want to save some sensitive data (passwords, PIN numbers, etc.) to disk in a secure manner in one of my programs. What is the easiest/best way to accomplish strong file encryption in Python? ...
113
by: Bonj | last post by:
I was in need of an encryption algorithm to the following requirements: 1) Must be capable of encrypting strings to a byte array, and decyrpting back again to the same string 2) Must have the same...
7
by: Alan Silver | last post by:
Hello, I am writing a page where sensitive data is collected (over SSL) and stored in a database. I have been looking at the .NET encryption classes, but am a bit confused as to which is best...
3
by: Chuck P | last post by:
I need to deploy and asp.net 2.0 application that has dpapi/machine encrypted connection strings. I tried using the VS Build Publish menu selection and then putting the encryption in the...
11
by: John Williams | last post by:
I've written a simple program to do XOR encryption as my first foray into understanding how encryption works. The code compiles fine, however it segmentation faults on every run. using gdb to...
8
by: manmit.walia | last post by:
Hello Everyone, Long time ago, I posted a small problem I had about converting a VB6 program to C#. Well with the help with everyone I got it converted. But I overlooked something and don't...
19
by: klenwell | last post by:
Another request for comments here. I'd like to accomplish something like the scheme outlined at this page here: http://tinyurl.com/3dtcdr In a nutshell, the form uses javascript to hash...
9
by: Betikci Boris | last post by:
I get bored last night and wrote a script that uses xor for encrypt- decrypt, however it woks fine under linux 2.6.25, text and documents are ok, but fails on compressed files *.jpg, *.pdf , etc ....
0
by: Jon.Hakkinen | last post by:
Hi all, I'm on DB2 9.5 fp 0 on Windows. I have a simple SQL stored procedure which uses the Encrypt() function to insert data in a table. I do not set the encryption password inside the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.