[RELEASE] Random String Generator 09-16-2016, 04:06 PM
#1
Hello folks,
Today i'm going to present you a nice class that you can use in any project you want.
Its purpose is to generate random strings with a normal entropy range. To do this it reads method names, class names and namespaces from all loaded libraries.
A simple usage :
Here there are some example outputs from the generator :
Enjoy!
Today i'm going to present you a nice class that you can use in any project you want.
Its purpose is to generate random strings with a normal entropy range. To do this it reads method names, class names and namespaces from all loaded libraries.
Code:
public class RandomStringGenerator
{
private Random Random;
private List<string> names;
public RandomStringGenerator(Random random)
{
Random = random;
LoadStrings();
}
public RandomStringGenerator() : this(new Random())
{
}
public string GetRandomString(int len)
{
StringBuilder sb = new StringBuilder();
while(sb.Length < len)
{
sb.Append(names[Random.Next(0, names.Count)] + names[Random.Next(0, names.Count)]);
}
return sb.ToString();
}
private void LoadStrings()
{
names = new List<string>();
foreach(Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
{
foreach(Type t in assembly.GetExportedTypes())
{
names.Add(t.Namespace);
names.Add(t.Name);
foreach(MethodInfo m in t.GetMethods())
{
names.Add(m.Name);
}
}
}
}
}A simple usage :
Code:
RandomStringGenerator rsg = new RandomStringGenerator();
string randomString = rsg.GetRandomString(10);
Console.WriteLine(randomString);Here there are some example outputs from the generator :
Code:
add_LostFocusget_RecreatingHandle
add_Clickget_EventLog
get_DisplayMemberToolStripItemEventArgs
get_DomainManagerget_ReadMethods
get_TypeIdset_Name
Equalsget_SourceColumn
set_GripMarginGetHashCode
set_RightToLeftIXmlSchemaInfo
set_AnyAttributeget_UnhandledAttributes
GetTypeadd_DragEnterEnjoy!
![[+]](https://sinister.ly/images/modern/collapse_collapsed.png)













