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