c#错误cs0117'System.Diagnostics.Debug'不包含'Log'的定义

时间:2019-12-05 18:03:50

标签: c#

我不知道为什么会收到此错误。由于我们使用的是chromebook,所以我在学校使用Repl.it,但我认为C#不会有所不同。我正在调试一些代码,只是为了查看它在控制台中的外观,但这只是行不通。我刚收到错误。我正在使用System.Diagnostics,System.IO和System。

我非常了解C#,所以我认为我没有丢失任何东西。我相信这只是一个Repl.it问题。

这是我的C#代码:

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

请注意,这不是真正的暴力破解者。我只是为了好玩而已。

0 个答案:

没有答案