public void SerializeNotes() { var binFormatter = new BinaryFormatter(); byte[] serialized; using (var memory = new MemoryStream()) { binFormatter.Serialize(memory, _notes); serialized = memory.ToArray(); } byte[] toFile = NotebookCryptography.Encode( serialized, ConstantKeeper.Key, ConstantKeeper.IV); NotebookModelIO.SaveNotesIV(toFile); }
public void DeSerializeNotes() { byte[] readBytes = NotebookModelIO.ReadNotesIV(); byte[] decodedBytes = NotebookCryptography.Decode( readBytes, ConstantKeeper.Key, ConstantKeeper.IV ); var binFormatter = new BinaryFormatter(); using (var memory = new MemoryStream(decodedBytes)) { var noteList = binFormatter.Deserialize(memory) as List <Note>; if (noteList != null) { _notes = noteList; } } }