예제 #1
0
        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);
        }
예제 #2
0
        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;
                }
            }
        }