encryption of a dataset

M

Mike Peretz

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?
 

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

Top