Gen a password

This commit is contained in:
Tim Young 2017-08-01 08:42:28 -05:00
parent 83dfef6ad2
commit 7b731e22a4
1 changed files with 27 additions and 0 deletions

View File

@ -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);
}
}
}