Stored Hashed Password: howque123. Input Password: howque123. Invalid Base64 String

Could you fix this issue and add improvements?

private string HashPassword(string password)
{
    // Generate a random salt
    byte[] salt;
    new RNGCryptoServiceProvider().GetBytes(salt = new byte[16]);

    // Create a password hash using PBKDF2
    using (var pbkdf2 = new Rfc2898DeriveBytes(password, salt, 10000, HashAlgorithmName.SHA256))
    {
        byte[] hash = pbkdf2.GetBytes(20); // 20 is the size of the hash

        // Use Convert.ToBase64String directly on the hashBytes
        string base64Hash = Convert.ToBase64String(hash);

        // Combine salt and hash for storage if needed
        byte[] hashBytes = new byte[36]; // 16 for salt + 20 for hash
        Array.Copy(salt, 0, hashBytes, 0, 16);
        Array.Copy(hash, 0, hashBytes, 16, 20);

        return base64Hash;
    }
}

private bool VerifyPassword(string inputPassword, string hashedPassword)
{
    try
    {
        // Debugging: Print hashed password and input password
        Console.WriteLine($"Stored Hashed Password: {hashedPassword}");
        Console.WriteLine($"Input Password: {inputPassword}");

        // Check if the hashed password is a valid Base64 string
        if (!IsValidBase64String(hashedPassword))
        {
            Console.WriteLine("Invalid Base64 String");
            return false;
        }

        // Convert the base64-encoded string back to bytes
        byte[] hashBytes = Convert.FromBase64String(hashedPassword);

        // Debugging: Print hash bytes
        Console.WriteLine($"Decoded Hash Bytes: {BitConverter.ToString(hashBytes)}");

        // Extract the salt and hash from the combined bytes
        byte[] salt = new byte[16];
        Array.Copy(hashBytes, 0, salt, 0, 16);
        byte[] inputHash;
        using (var pbkdf2 = new Rfc2898DeriveBytes(inputPassword, salt, 10000, HashAlgorithmName.SHA256))
        {
            inputHash = pbkdf2.GetBytes(20); // 20 is the size of the hash
        }

        // Debugging: Print input hash bytes
        Console.WriteLine($"Input Hash Bytes: {BitConverter.ToString(inputHash)}");

        // Compare the computed hash with the stored hash
        for (int i = 0; i < 20; i++)
        {
            if (inputHash[i] != hashBytes[i + 16])
            {
                return false;
            }
        }
        return true;
    }
    catch (Exception ex)
    {
        // Handle the exception and print a message
        Console.WriteLine($"Error in VerifyPassword: {ex.Message}");
        return false;
    }
}

private bool IsValidBase64String(string s)
{
    try
    {
        Convert.FromBase64String(s);
        return true;
    }
    catch
    {
        return false;
    }
}

// Use a secure method to store and retrieve connection strings
private string GetConnectionString()
{
    // Replace this with a secure method to retrieve your connection string
    return "Data Source=DESKTOP-E8D96UU\\SQLEXPRESS;Initial Catalog=sfd_loader;Integrated Security=True;Encrypt=False";
}

public static string SetValueForText1 = "";
public static string SetValueForText2 = "";

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

    // Hash the entered password before checking it
    string hashedPassword = HashPassword(password.Text);

    using (SqlConnection connection = new SqlConnection(GetConnectionString()))
    {
        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 storedPassword = 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); // Use the hashed value
                    }
                    else if (hashedHwid == hashedHwidFromDb && VerifyPassword(password.Text, storedPassword))
                    {
                        SetValueForText1 = login.Text + " // Admin";
                        this.Hide();
                        var form1 = new Form2();
                        form1.Closed += (s, args) => this.Close();
                        form1.Show();
                    }
                    else
                    {
                        MessageBox.Show("Credentials are incorrect!");
                    }
                }
                else
                {
                    MessageBox.Show("Username is incorrect!");
                }
            }
        }
    }

    if (checkBox1.Checked)
    {
        HowqueCheats.Properties.Settings.Default.Username = login.Text;
        HowqueCheats.Properties.Settings.Default.Password = password.Text; // Save the plaintext password for simplicity
        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(GetConnectionString()))
    {
        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();
        }
    }
}