I don't know why I am getting this error. I am using Repl.it at school since we are using chromebooks, but I don't think the C# would be different. I'm debugging some code just to see what it looks like in the console, but it just simply won't work. I am just getting errors. I'm using System.Diagnostics, System.IO, and System.
I know C# pretty well, so I don't think I'm missing anything. I believe it's just simply a Repl.it issue.
Here is my C# code:
public char firstchar = 'a';
public char lasrchar = 'z';
public int passwordLength = 6;
public long tries = 0;
public bool done = false;
public string password = "hey";
public void CreatePasswords(string keys)
{
if (keys == password)
{
done = true;
}
if (keys.Length == passwordLength || done == true)
{
return;
}
for (char c = firstchar; c <= lasrchar; c++)
{
tries++;
CreatePasswords(keys + c);
}
}
static void Main(string[] args)
{
Program program = new Program();
Console.ForegroundColor = ConsoleColor.DarkRed;
Console.WriteLine("welcome to my brute force password cracker.");
System.Threading.Thread.Sleep(3000);
Console.Write("this program was created by ");
Console.ForegroundColor = ConsoleColor.Red;
Console.Write("Volt");
Console.ForegroundColor = ConsoleColor.DarkRed;
Console.WriteLine(".");
System.Threading.Thread.Sleep(2800);
Console.WriteLine("note that passwords found in under a second won't tell you how many passwords per second they got.");
System.Threading.Thread.Sleep(5000);
Console.ForegroundColor = ConsoleColor.DarkYellow;
Console.Write("\nplease enter your password > ");
program.password = Convert.ToString(Console.ReadLine());
program.password = program.password.ToLower();
//Debug.Log(program.password = Convert.ToString(Console.ReadLine()));
//Debug.Log(program.password = program.password.ToLower());
Console.ForegroundColor = ConsoleColor.DarkRed;
Console.WriteLine("\ncracking your password...");
Stopwatch timer = Stopwatch.StartNew();
program.passwordLength = program.password.Length;
program.CreatePasswords(string.Empty);
timer.Stop();
//Debug.Log(program.passwordLength = program.password.Length);
//Debug.Log(program.CreatePasswords(string.Empty));
long elapsedMs = timer.ElapsedMilliseconds;
double elapsedTime = elapsedMs / 1000;
if (elapsedTime > 0)
{
Console.WriteLine("\n\nyour password has been found! here are the statistics:");
Console.WriteLine("----------------------------------");
Console.WriteLine("password: {0}", program.password);
Console.WriteLine("password length: {0}", program.passwordLength);
Console.WriteLine("tries: {0}", program.tries);
string plural = "seconds";
if (elapsedTime == 1)
{
plural = "second";
}
Console.WriteLine("time to crack: {0} {1}", elapsedTime, plural);
Console.WriteLine("passwords per second: {0}", (long)(program.tries / elapsedTime));
}
else
{
Console.WriteLine("\n\nyour password has been found! here are the statistics:");
Console.WriteLine("----------------------------------");
Console.WriteLine("password: {0}", program.password);
Console.WriteLine("password length: {0}", program.passwordLength);
Console.WriteLine("tries: {0}", program.tries);
Console.WriteLine("time to crack: {0} seconds", elapsedTime);
}
System.Threading.Thread.Sleep(5000);
Console.ForegroundColor = ConsoleColor.DarkYellow;
Console.Write("\n\npress any key to close");
Console.ReadKey();
}
Please note, this isn't an actual brute force password cracker. I simply made this for fun.