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?
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?