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; + /// + /// The characters we use for passwords and salts. + /// + 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); + } + } }