Here is my code:
public static void Save(T toSerialize, string fileSpec) {
BinaryFormatter formatter = new BinaryFormatter();
DESCry
One small typo: your Load
method should use des.CreateDecryptor
, like this:
public static T Load<T>(string fileSpec)
{
BinaryFormatter formatter = new BinaryFormatter();
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
using (FileStream stream = File.OpenRead(fileSpec))
{
using (CryptoStream cryptoStream =
new CryptoStream(stream, des.CreateDecryptor(key, iv),
CryptoStreamMode.Read))
{
return (T)formatter.Deserialize(cryptoStream);
}
}
}