Code:
internal class CardGenerator
{
private static readonly char[] Charset = "abcdefghijklmnopqrstuvwxyz0123456789".ToCharArray();
private static readonly Random random = new Random();
/// <summary>
/// Gets a randomly generated time card code. Example: 3420-666698-16081-009008-6060
/// </summary>
/// <value>The get time card.</value>
/// 10/27/2008 9:15 AM
public static string GetTimeCard
{
get
{
StringBuilder sb = new StringBuilder();
for (int j = 1; j <= 29; j++)
{
int next = random.Next(10);
if (j == 5 || j == 12 || j == 18 || j == 25)
{
sb.Append("-");
continue;
}
sb.Append(next.ToString());
}
return sb.ToString();
}
}
/// <summary>
/// Gets a randomy generated Trading Card Game code
/// </summary>
/// <value>The get TCG card.</value>
/// 10/27/2008 9:15 AM
public static string GetTCGCard
{
get
{
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 29; i++)
{
if (i == 4 || i == 12 || i == 18 || i == 24)
{
sb.Append("-");
continue;
}
sb.Append(Charset[random.Next(Charset.Length)]);
}
return sb.ToString().ToUpper();
}
}
/// <summary>
/// Gets a randomly generated CD key. Example: RMXI7O-83DY-ZU6INW-8FMB-72XSG4
/// </summary>
/// <value>The get CD key.</value>
/// 10/27/2008 9:15 AM
public static string GetCDKey
{
get
{
StringBuilder sb = new StringBuilder();
for (int i = 1; i <= 30; i++)
{
if (i == 7 || i == 12 || i == 19 || i == 24)
{
sb.Append('-');
continue;
}
sb.Append(Charset[random.Next(Charset.Length)]);
}
return sb.ToString().ToUpper();
}
}
/// <summary>
/// Gets a randomly generated Blizzard authenticator code. (Length ranges from 6-8 digits only.)
/// </summary>
/// <value>The get authenticator.</value>
/// 10/27/2008 9:15 AM
public static string GetAuthenticator
{
get
{
int rand = random.Next(6, 9);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < rand; i++)
{
sb.Append(random.Next(10));
}
return sb.ToString();
}
}
}
There you go. Add a GUI, and you have yourself a generator for the 4 major WoW codes.
Call the following:
Code:
string myCDKey = CardGenerator.GetCDKey;
And you have a random CDKey generated.
Enjoy.
This kind of stuff doesn't need to be secret iradiation. It's not difficult to create, and it's not hard to understand either.
+Rep for the contribution though.