Gen a password
This commit is contained in:
		@@ -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);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user