From 7b731e22a46884a64baa2b1e9968b9db88ac41d8 Mon Sep 17 00:00:00 2001
From: Tim Young <tim.young@lightsys.org>
Date: Tue, 1 Aug 2017 08:42:28 -0500
Subject: [PATCH] Gen a password

---
 .../TrippleDESDocumentEncryption.cs           | 27 +++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/EduNetworkBuilder/TrippleDESDocumentEncryption.cs b/EduNetworkBuilder/TrippleDESDocumentEncryption.cs
index 2544d54..8f3bef9 100644
--- a/EduNetworkBuilder/TrippleDESDocumentEncryption.cs
+++ b/EduNetworkBuilder/TrippleDESDocumentEncryption.cs
@@ -17,6 +17,11 @@ namespace EduNetworkBuilder
         protected XmlDocument docValue;
         protected TripleDES algValue;
 
+        /// <summary>
+        /// The characters we use for passwords and salts.
+        /// </summary>
+        protected const string PWChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_.!#$^*";
+
         public TrippleDESDocumentEncryption(XmlDocument Doc, TripleDES Key)
         {
             if (Doc != null)
@@ -118,5 +123,27 @@ namespace EduNetworkBuilder
 
         }
 
+        protected static string GenCharString(Random RanGen, int length)
+        {
+            int next;
+            string result = "";
+            for(int i=0; i< length; i++)
+            {
+                next = RanGen.Next(PWChars.Length);
+                result += PWChars[next];
+            }
+            return result;
+        }
+
+        public static string GenSalt(Random RanGen)
+        {
+            return GenCharString(RanGen, 20);
+        }
+
+        public static string GenUserPW(Random RanGen)
+        {
+            return GenCharString(RanGen, 6);
+        }
+
     }
 }