From e4edd9bf5afab476ae963d88a2519c49b98f6ba6 Mon Sep 17 00:00:00 2001 From: Tim Young Date: Wed, 9 Aug 2017 16:03:19 -0500 Subject: [PATCH] convert personclass writer to xml document so we can encrypt. --- EduNetworkBuilder/PersonClass.cs | 26 ++++++++++++------- .../TrippleDESDocumentEncryption.cs | 2 -- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/EduNetworkBuilder/PersonClass.cs b/EduNetworkBuilder/PersonClass.cs index 8739f64..09d9ed9 100644 --- a/EduNetworkBuilder/PersonClass.cs +++ b/EduNetworkBuilder/PersonClass.cs @@ -182,17 +182,23 @@ namespace EduNetworkBuilder settings.NewLineOnAttributes = true; if (doRotation && File.Exists(filename)) NB.MoveFileWithRotation(filename); //make a backup of the file - XmlWriter writer = XmlWriter.Create(filename, settings); - //Now we write the file: - writer.WriteStartDocument(); - writer.WriteStartElement("EduNetworkBuilderUser"); - writer.WriteComment("This is a user file for EduNetworkBuilder."); - Save(writer); - writer.WriteEndElement(); - writer.WriteEndDocument(); - writer.Flush(); - writer.Close(); + //Generate a doc that has a writer attached. All the normal save funcs work with the writer, + //But, we can encrypt the XmlDocument + XmlDocument doc = new XmlDocument(); + using (XmlWriter writer = doc.CreateNavigator().AppendChild()) + { + //XmlWriter writer = XmlWriter.Create(filename, settings); + + //Now we write the file: + writer.WriteStartDocument(); + writer.WriteStartElement("EduNetworkBuilderUser"); + writer.WriteComment("This is a user file for EduNetworkBuilder."); + Save(writer); + writer.WriteEndElement(); + writer.WriteEndDocument(); + } + doc.Save(filename); } diff --git a/EduNetworkBuilder/TrippleDESDocumentEncryption.cs b/EduNetworkBuilder/TrippleDESDocumentEncryption.cs index e0f02fb..593744c 100644 --- a/EduNetworkBuilder/TrippleDESDocumentEncryption.cs +++ b/EduNetworkBuilder/TrippleDESDocumentEncryption.cs @@ -140,8 +140,6 @@ namespace EduNetworkBuilder //The decryption failed. throw new LoginException("Key/Salt unable to decrypt."); } - - } protected static string GenCharString(Random RanGen, int length)