MyPasswordStrength.NET.MAUI 1.0.0

dotnet add package MyPasswordStrength.NET.MAUI --version 1.0.0
                    
NuGet\Install-Package MyPasswordStrength.NET.MAUI -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MyPasswordStrength.NET.MAUI" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MyPasswordStrength.NET.MAUI" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="MyPasswordStrength.NET.MAUI" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MyPasswordStrength.NET.MAUI --version 1.0.0
                    
#r "nuget: MyPasswordStrength.NET.MAUI, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package MyPasswordStrength.NET.MAUI@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MyPasswordStrength.NET.MAUI&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=MyPasswordStrength.NET.MAUI&version=1.0.0
                    
Install as a Cake Tool

MyPasswordStrength.NET.MAUI

.NET Build & Test

A .NET MAUI library for validating password strength based on customizable complexity requirements.

Background

Define your password strength complexity requirements with ease using the library.

The package provides a PasswordStrengthEntry Entry that you can use to validate passwords in your .NET MAUI applications.

You can set the password strength requirements through the properties of the MyPasswordStrengthOptions class and pass the options to the Entry.

The special characters considered in the validation are: @$!%*?&.

You can modify this set of special characters by setting the SpecialCharacters property of the options to a custom string of special characters.

Sample Usage

using Microsoft.Maui.Controls.Shapes;
using MyPasswordStrength;
using System.Runtime.Versioning;

namespace MyTestMAUIAPP.Pages;

[SupportedOSPlatform("android")]
[SupportedOSPlatform("ios")]
[SupportedOSPlatform("maccatalyst")]
[SupportedOSPlatform("windows")]
public class Registration : ContentPage
{    
    private readonly PasswordStrengthEntry _entry;
    private readonly Border _border;
    private readonly Label _errorLabel;

    public Registration()
    {
        var content = new VerticalStackLayout
        {
            Children = {
                new Label {
                    HorizontalOptions = LayoutOptions.Center,
                    VerticalOptions = LayoutOptions.Center,
                    Text = "Welcome to .NET MAUI!"
                }
            }
        };

        _entry = new PasswordStrengthEntry(HandleOnValidation, GetOptions(), "Enter your password")
        {
            HorizontalOptions = LayoutOptions.Fill,
            VerticalOptions = LayoutOptions.Fill
        };        

        _border = new Border
        {
            Stroke = Colors.Black,          // Border color
            StrokeThickness = 1,          // Border width in device-independent units
            StrokeShape = new Rectangle(),  //Square border 
            Margin = 10,
            Content = _entry            
        };

        _errorLabel = new Label
        {
            Text = "Password must be at least 9 chars, 2 uppercase, 3 lowercase, 2 digit, 2 special char, no more than 2 same consecutive chars, no more than 3 consecutive ascending digits, no more than 3 consecutive descending digits",
            TextColor = Colors.Red,
            HorizontalOptions = LayoutOptions.Center,
            VerticalOptions = LayoutOptions.Center,
            IsVisible = false
        };

        content.Children.Add(_border);
        content.Children.Add(_errorLabel);

        Content = content;
    }

    private MyPasswordStrengthOptions GetOptions()
    {
        var options = new MyPasswordStrengthOptions();

        options.MinimumLength = 9;
        options.RequireUppercase = true;
        options.MinimumUppercase = 2;
        options.RequireLowercase = true;
        options.MinimumLowercase = 3;
        options.RequireDigit = true;
        options.MinimumDigit = 2;
        options.RequireSpecialCharacter = true;
        options.MinimumSpecialCharacter = 2;
        options.RequireMaximumNoOfSameConsecutiveCharacters = true;
        options.MaximumNoOfSameConsecutiveCharacters = 2;
        options.RequireMaximumNoOfConsecutiveAscendingDigits = true;
        options.MaximumNoOfConsecutiveAscendingDigits = MaximumNoOfConsecutiveDigits.Three;
        options.RequireMaximumNoOfConsecutiveDescendingDigits = true;
        options.MaximumNoOfConsecutiveDescendingDigits = MaximumNoOfConsecutiveDigits.Three;

        return options;
    }

    private async void HandleOnValidation(string pwd, bool isValid)
    {
        if (isValid)
        {
            _border.Stroke = Colors.Green;
            _errorLabel.IsVisible = false;
        }
        else
        {
            _border.Stroke = Colors.Red;
            _errorLabel.IsVisible = true;
        }
    }
}

License

MIT © VeritasSoftware

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-android36.0 is compatible.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-ios26.0 is compatible.  net10.0-maccatalyst was computed.  net10.0-maccatalyst26.0 is compatible.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed.  net10.0-windows10.0.19041 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 40 6/9/2026

Initial release.