BlazorVerificationCaptcha 0.1.1
See the version list below for details.
dotnet add package BlazorVerificationCaptcha --version 0.1.1
NuGet\Install-Package BlazorVerificationCaptcha -Version 0.1.1
<PackageReference Include="BlazorVerificationCaptcha" Version="0.1.1" />
paket add BlazorVerificationCaptcha --version 0.1.1
#r "nuget: BlazorVerificationCaptcha, 0.1.1"
// Install BlazorVerificationCaptcha as a Cake Addin #addin nuget:?package=BlazorVerificationCaptcha&version=0.1.1 // Install BlazorVerificationCaptcha as a Cake Tool #tool nuget:?package=BlazorVerificationCaptcha&version=0.1.1
BlazorVerificationCaptcha
A simple solution to verify users using a simple captcha with a current limit of six characters (changed in next update).
Technologies
Created using
- .NET Core 6.0
NuGet/Dependencies used
- SkiaSharp
- SkiaSharp.NativeAssets.Linux.NoDependencies - Needed for Linux (See FAQ)!
Features
Nuget
- BlazorVerificationCaptcha package is available on NuGet: BlazorVerificationCaptcha
General
- Provides a simple and easy-to-use solution for implementing captcha verification in Blazor applications.
- The current version supports a captcha length of up to six characters.
Screenshots
A GIF, to see the image and variable content change on page reload
A image, to get the original quality that the image is displayed in
Usage (For more, see examples)
To use BlazorVerificationCaptcha in your Blazor application, follow these steps:
- Install the BlazorVerificationCaptcha package from NuGet.
- Add
@using BlazorVerificationCaptcha
inside the _Imports.razor - Implement the captcha component in your desired location, by adding
<VerificationCaptcha />
- Add
ExampleVariable = VerificationCaptcha.GenerateCaptchaContent();
insideOnInitializedAsync()
, as this code generates the image
Example (Component)
Here is an example of how you can use BlazorVerificationCaptcha in your Blazor component:
<VerificationCaptcha />
@code {
private string ExampleVariable;
protected override Task OnInitializedAsync()
{
ExampleVariable = VerificationCaptcha.GenerateCaptchaContent();
return base.OnInitializedAsync();
}
}
Example (Generator)
Here is an example of how you can use the generator without the component, to get the values and display it by yourself
<p>@ExampleVariable.Text</p>
<p>@ExampleVariable.Image</p>
@code {
private (string Image, string Text) ExampleVariable;
protected override Task OnInitializedAsync()
{
ExampleVariable = CaptchaGenerator.GenerateCaptcha();
return base.OnInitializedAsync();
}
}
This example doesn't show how to handle checking if the captcha is correct but you have the ExampleVariable, so
you can easily just do if(ExampleVariable.Equals(ExampleInputVariable, StringComparison.InvariantCulture))
.
FAQ
Notes on linux
I tried using it on linux I learned that in order to run it there you eventually have to install missing packages, I'm running CentOs so I executed:
yum install fontconfig freetype freetype-devel fontconfig-devel libstdc++
It could be that only 'fontconfig' is needed but I wanted to be sure, so I the captcha is only showing colored backgrounds and no content, install these dependencies you need them.
What do I have to be aware of?
The image is displayed using base64, which adds some overhead. You should test if this method meets your requirements. In future updates, an alternative way of displaying the captcha image will be implemented.
License
Software: BlazorVerificationCaptcha
License: GNU General Public License v3.0
Roadmap
- Implement an alternative way to display the captcha image, besides base64
- Allow customization of the captcha length, dimension etc.
- Maybe implement features for barrier free things like text2speech etc.
Product | Versions 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 was computed. 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 was computed. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
-
net6.0
- SkiaSharp (>= 2.88.3)
- SkiaSharp.NativeAssets.Linux.NoDependencies (>= 2.88.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Include of 'SkiaSharp.NativeAssets.Linux.NoDependencies' for linux, moved from property CaptchaBackup, to method GenerateCaptchaContent(), new option to enable or disable the use of numbers inside the captcha, changed the image from png to jpg, to save a tiny bit of image size