DNTCaptcha.Blazor 1.2.3

dotnet add package DNTCaptcha.Blazor --version 1.2.3                
NuGet\Install-Package DNTCaptcha.Blazor -Version 1.2.3                
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="DNTCaptcha.Blazor" Version="1.2.3" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DNTCaptcha.Blazor --version 1.2.3                
#r "nuget: DNTCaptcha.Blazor, 1.2.3"                
#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.
// Install DNTCaptcha.Blazor as a Cake Addin
#addin nuget:?package=DNTCaptcha.Blazor&version=1.2.3

// Install DNTCaptcha.Blazor as a Cake Tool
#tool nuget:?package=DNTCaptcha.Blazor&version=1.2.3                

DNTCaptcha.Blazor

DNTCaptcha.Blazor

DNTCaptcha.Blazor is a captcha generator for the interactive Blazor based applications. It uses the standard HTML5 Canvas API to draw the captcha and that's why it's compatible with both interactive (not SSR!) Blazor WASM and Server apps. It no longer uses the System.Drawing.Common package which has serious cross platform and stability issues.

Install via NuGet

To install DNTCaptcha.Blazor, run the following command in the Package Manager Console:

Nuget

PM> Install-Package DNTCaptcha.Blazor

You can also view the package page on NuGet.

Usage

After installing the DNTCaptcha.Blazor package, add the following definition to the _Imports.razor file:

@using DNTCaptcha.Blazor

Then to use it, add its new tag and settings to your view. Here you will need two properties and one Compare attribute to work with it:

[Required]
[Compare(nameof(CaptchaText1), ErrorMessage = "The entered `Security Number` is not correct.")]
public string EnteredCaptchaText1 { set; get; }

public string CaptchaText1 { set; get; }
<EditForm Model="Model" OnValidSubmit="DoLoginAsync">
    <InputText name="SecurityNumber" @bind-Value="Model.EnteredCaptchaText1" />
    <DntInputCaptcha @bind-Value="Model.CaptchaText1" />

The EnteredCaptchaText1 will receive the entered text from the user and the CaptchaText1 contains the automatically generated captcha code. Now the Compare attribute will compare these two values during the OnValidSubmit event to provide an standard and clean validation.

Note: Using the Compare attribute will make the whole process nicer, but it's not mandatory. You can omit it and then do the comparison manually on the form's submit (if (userLoginViewModel.CaptchaText1.Equals(userLoginViewModel.EnteredCaptchaText1)){ }). Now if the inputs don't match, redraw the captcha with the new data. Also to protect the form against brute-forces, you can use the AbsoluteExpiration parameter to control the refresh frequency of the captcha.

Supported Languages

You can find all of the currently supported languages here. To add a new language, kindly contribute by editing the following files:

Samples

DNTCaptcha.Blazor

Demo

You can see a demo of this component with all of its different supported DisplayModes here

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on DNTCaptcha.Blazor:

Package Downloads
AonBlzrDevOps

Package Description

AMS-Utl

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.2.3 4,805 5/10/2024
1.2.2 103 5/10/2024
1.2.1 1,794 2/28/2024
1.2.0 142 2/23/2024
1.1.4 2,624 3/4/2023
1.1.3 1,496 11/15/2022
1.1.2 511 9/12/2022
1.1.1 1,628 11/9/2021
1.1.0 253 10/24/2021
1.0.0 353 8/14/2021