473,405 Members | 2,354 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,405 software developers and data experts.

encryption of a dataset

I am trying to encrypt and decrypts a dataset using ds.WriteXml and
ds.ReadXml. I am able to encrypt the dataset but I can never read the data
back...I get an exception of Bad Data

for example, for writing there seems to be no problem...

using (IsolatedStorageFileStream storeStream = new
IsolatedStorageFileStream("reg.xml",
FileMode.Create,
FileAccess.ReadWrite,
FileShare.Read,
m_storeFile))
{
using (CryptoStream cryptStream = new CryptoStream(storeStream,
m_encryptor, CryptoStreamMode.Write))
{
m_dsRegistration.WriteXml(cryptStream, XmlWriteMode.WriteSchema);
}
}

for reading...

using (IsolatedStorageFileStream storeStream = new
IsolatedStorageFileStream("reg.xml",
FileMode.Open,
FileAccess.ReadWrite,
FileShare.Read,
m_storeFile))
{

using (CryptoStream cryptStream = new CryptoStream(storeStream,
m_decryptor, CryptoStreamMode.Read))
{
// load the data with the schema. After this line we should have all
our
// registration information.

m_dsRegistration.ReadXml(cryptStream, XmlReadMode.ReadSchema);

}
}
}

However... cryptStream.Read(...) works does not cause an exception.

Any ideas?


Jul 21 '05 #1
2 2418
Ivan Medvedev has a nice example of using CryptoStreams:
http://blogs.gotdotnet.com/ivanmed/

http://blogs.gotdotnet.com/ivanmed/P...6-5973106935a4

You could try building up from there to see where the problem lies.

-mike
MVP

"Mike Peretz" <m_******@sympatico.ca> wrote in message
news:iI********************@news20.bellglobal.com. ..
I am trying to encrypt and decrypts a dataset using ds.WriteXml and
ds.ReadXml. I am able to encrypt the dataset but I can never read the data
back...I get an exception of Bad Data

for example, for writing there seems to be no problem...

using (IsolatedStorageFileStream storeStream = new
IsolatedStorageFileStream("reg.xml",
FileMode.Create,
FileAccess.ReadWrite,
FileShare.Read,
m_storeFile))
{
using (CryptoStream cryptStream = new CryptoStream(storeStream,
m_encryptor, CryptoStreamMode.Write))
{
m_dsRegistration.WriteXml(cryptStream, XmlWriteMode.WriteSchema);
}
}

for reading...

using (IsolatedStorageFileStream storeStream = new
IsolatedStorageFileStream("reg.xml",
FileMode.Open,
FileAccess.ReadWrite,
FileShare.Read,
m_storeFile))
{

using (CryptoStream cryptStream = new CryptoStream(storeStream,
m_decryptor, CryptoStreamMode.Read))
{
// load the data with the schema. After this line we should have all
our
// registration information.

m_dsRegistration.ReadXml(cryptStream, XmlReadMode.ReadSchema);

}
}
}

However... cryptStream.Read(...) works does not cause an exception.

Any ideas?

Jul 21 '05 #2
Thanks.
"Michael Giagnocavo [MVP]" <mg*******@Atrevido.net> wrote in message
news:O4**************@TK2MSFTNGP10.phx.gbl...
Ivan Medvedev has a nice example of using CryptoStreams:
http://blogs.gotdotnet.com/ivanmed/

http://blogs.gotdotnet.com/ivanmed/P...5-40b9-ace6-59
73106935a4
You could try building up from there to see where the problem lies.

-mike
MVP

"Mike Peretz" <m_******@sympatico.ca> wrote in message
news:iI********************@news20.bellglobal.com. ..
I am trying to encrypt and decrypts a dataset using ds.WriteXml and
ds.ReadXml. I am able to encrypt the dataset but I can never read the data back...I get an exception of Bad Data

for example, for writing there seems to be no problem...

using (IsolatedStorageFileStream storeStream = new
IsolatedStorageFileStream("reg.xml",
FileMode.Create,
FileAccess.ReadWrite,
FileShare.Read,
m_storeFile))
{
using (CryptoStream cryptStream = new CryptoStream(storeStream,
m_encryptor, CryptoStreamMode.Write))
{
m_dsRegistration.WriteXml(cryptStream, XmlWriteMode.WriteSchema);
}
}

for reading...

using (IsolatedStorageFileStream storeStream = new
IsolatedStorageFileStream("reg.xml",
FileMode.Open,
FileAccess.ReadWrite,
FileShare.Read,
m_storeFile))
{

using (CryptoStream cryptStream = new CryptoStream(storeStream,
m_decryptor, CryptoStreamMode.Read))
{
// load the data with the schema. After this line we should have all our
// registration information.

m_dsRegistration.ReadXml(cryptStream, XmlReadMode.ReadSchema);

}
}
}

However... cryptStream.Read(...) works does not cause an exception.

Any ideas?


Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

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...
3
by: Anon | last post by:
I made this class to encrypt my DataSet before saving it to disk. So, first in the main program I write the DataSet to XML in a MemoryStream. I pass this stream to the E_File sub, which encrypts...
3
by: Mike Peretz | last post by:
I am trying to encrypt and decrypts a dataset using ds.WriteXml and ds.ReadXml. I am able to encrypt the dataset but I can never read the data back...I get an exception of Bad Data for example,...
1
by: BobF | last post by:
I am working with xml files for my program's database. I want to encrypt the xml file. I want to use the Dataset.WriteXml(Stream, XmlWriteMode.WriteSchema). How can I use a cryptostream with this...
4
by: pintu | last post by:
Hello everybody.. I hav some confusion regarding asymmetric encryption.As asymmetric encryption it there is one private key and one public key.So any data is encrypted using private key and the...
0
by: Fidget Brain | last post by:
i am developing a set of web service methods which return reporting data. ideally i do not want to use HTTPS due to the extra performance hit. what would be ideal is to encrypt only that data which...
2
by: Earl | last post by:
I'm adding password encryption to the Employees form. I have a strongly-typed dataset being used as the datasource for the EmployeesBindingSource, and the Employees table set as the datamember. All...
1
by: =?Utf-8?B?bWljcm9ob2Y=?= | last post by:
Short version: Is there a way to configure (preferably programmatically) the max encryption strength that will be used by the framework when connecting to a particular SSL-protected web service? ...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.