0

I have a key authentication system with BCrypt.NET with 100 hard-coded hashes.

At the time this was a quick fix to my authentication problem but now I'm realizing that I need to optimize this badly.

Authentication is client-side and the local machine itself processes the authentication. if you look at my current code: each hash is verified manually.

I need help optimizing this so in the future it will be quicker and having more hashes added will not cause performance problems.

Login Function:

public static void Login()
    {

        Console.Clear();
        Console.Write("enter your key: ");
        licenseKey = Console.ReadLine();
        string Hashes = @"hash list would go here, i have included 15 hashes in the source (i made them just for example purposes)";

        foreach (string hash in new MiscUtil.LineReader(() => new StringReader(Hashes)))
        {
            if (BCrypt.Net.BCrypt.Verify(licenseKey, hash) == true)
            {
                isAuthed = true;
            }

            else
            {

            }
        }

        if (isAuthed == true)
        {
            Console.WriteLine("Authentication Successful!");
            Console.ReadKey();
        }

        else
        {
            Console.WriteLine("Authentication Failed!");
            Console.ReadKey();
        }
    }

full source code example: https://pastebin.com/raw/HLh9VMQx

vx-dev
  • 1
  • 2
  • Possibly relevant: [Efficiently searching a massive file for a string in C#](https://stackoverflow.com/a/65984439/14868997) I'm not sure how bcrypt (or how you generated the hashes) is really relevant, as all you are doing is comparing some strings. – Charlieface Oct 02 '22 at 12:32

0 Answers0