Could you remove unecessary code. Make it more secure/effecient. Fix the hwid issue of not outputing the hwid and then the hashed hwid on the console. Fix probably the hwid is not retrieving it correctly

private string HashHwid(string input)
{
    using (SHA256 sha256 = SHA256.Create())
    {
        byte[] inputBytes = Encoding.UTF8.GetBytes(input);
        byte[] hashBytes = sha256.ComputeHash(inputBytes);
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < hashBytes.Length; i++)
        {
            sb.Append(hashBytes[i].ToString("x2"));
        }
        Console.WriteLine("Hashed HWID: " + sb.ToString());
        return sb.ToString();
    }
}

public static string SetValueForText1 = "";
public static string SetValueForText2 = "";
string connectionString = "Data Source=DESKTOP-E8D96UU\\SQLEXPRESS;Initial Catalog=sfd_loader;Integrated Security=True;Encrypt=False";

private void load_Click(object sender, EventArgs e)
{
    string hwid = GetHardwareID();
    string hashedHwid = HashHwid(hwid);

    using (SqlConnection connection = new SqlConnection(connectionString))
    {
        connection.Open();
        string query = "SELECT * FROM Accounts WHERE Username=@Username";
        using (SqlCommand command = new SqlCommand(query, connection))
        {
            command.Parameters.AddWithValue("@Username", login.Text);
            using (SqlDataReader reader = command.ExecuteReader())
            {
                if (reader.Read())
                {
                    string password = reader["Password"].ToString();
                    string hashedHwidFromDb = reader["hwid"].ToString();

                    if (string.IsNullOrEmpty(hashedHwidFromDb))
                    {
                        MessageBox.Show("HWID not found in database. Please update HWID.");
                        UpdateHwidInDatabase(login.Text, hashedHwid);
                    }
                    else if (hashedHwid == hashedHwidFromDb)
                    {
                        SetValueForText1 = login.Text + " // Admin";
                        this.Hide();
                        var form1 = new Form2();
                        form1.Closed += (s, args) => this.Close();
                        form1.Show();
                    }
                    else
                    {
                        MessageBox.Show("HWID is incorrect!");
                    }
                }
                else
                {
                    MessageBox.Show("Username is incorrect!");
                }
            }
        }
    }

    if (checkBox1.Checked)
    {
        HowqueCheats.Properties.Settings.Default.Username = login.Text;
        HowqueCheats.Properties.Settings.Default.Password = this.password.Text;
        HowqueCheats.Properties.Settings.Default.Save();
    }
    else
    {
        HowqueCheats.Properties.Settings.Default.Username = "";
        HowqueCheats.Properties.Settings.Default.Password = "";
        HowqueCheats.Properties.Settings.Default.Save();
    }
}

private void UpdateHwidInDatabase(string username, string hwid)
{
    string updateQuery = "UPDATE Accounts SET hwid=@Hwid WHERE Username=@Username";
    using (SqlConnection connection = new SqlConnection(connectionString))
    {
        connection.Open();
        using (SqlCommand updateCommand = new SqlCommand(updateQuery, connection))
        {
            // Trim the hwid value to the maximum allowed length
            updateCommand.Parameters.AddWithValue("@hwid", hwid.Length > 100 ? hwid.Substring(0, 100) : hwid);
            updateCommand.Parameters.AddWithValue("@Username", username);
            updateCommand.ExecuteNonQuery();
        }
    }
}

private string ExecuteCommand(string command)
{
    try
    {
        using (System.Diagnostics.Process process = new System.Diagnostics.Process())
        {
            System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo
            {
                FileName = "cmd.exe",
                RedirectStandardInput = true,
                RedirectStandardOutput = true,
                RedirectStandardError = true,
                UseShellExecute = false,
                CreateNoWindow = true
            };

            process.StartInfo = startInfo;
            process.Start();

            // Send the command to cmd.exe
            process.StandardInput.WriteLine(command);
            process.StandardInput.WriteLine("exit");

            // Read the command output
            string output = process.StandardOutput.ReadToEnd();
            string errors = process.StandardError.ReadToEnd();

            process.WaitForExit();

            if (string.IsNullOrEmpty(errors))
            {
                return output;
            }
            else
            {
                MessageBox.Show("Error executing command: " + errors);
                return string.Empty;
            }
        }
    }
    catch (Exception ex)
    {
        MessageBox.Show("Error executing command: " + ex.Message);
        return string.Empty;
    }
}

private string GetHardwareID()
{
    ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT UUID FROM Win32_ComputerSystemProduct");
    ManagementObjectCollection collection = searcher.Get();

    foreach (ManagementObject obj in collection)
    {
        return obj["UUID"].ToString();
    }

    return null;
}

private string ExtractUUID(string commandOutput)
{
    // Use regular expressions to extract the UUID in the correct format
    Regex uuidRegex = new Regex(@"^UUID\s+:\s+(.+)$", RegexOptions.IgnoreCase | RegexOptions.Multiline);
    Match uuidMatch = uuidRegex.Match(commandOutput);

    if (uuidMatch.Success)
    {
        // Take the first group as the UUID and trim any leading or trailing spaces
        return uuidMatch.Groups[1].Value.Trim();
    }

    return string.Empty;
}