NSCaptcha 1.0.7
dotnet add package NSCaptcha --version 1.0.7
NuGet\Install-Package NSCaptcha -Version 1.0.7
<PackageReference Include="NSCaptcha" Version="1.0.7" />
<PackageVersion Include="NSCaptcha" Version="1.0.7" />
<PackageReference Include="NSCaptcha" />
paket add NSCaptcha --version 1.0.7
#r "nuget: NSCaptcha, 1.0.7"
#:package NSCaptcha@1.0.7
#addin nuget:?package=NSCaptcha&version=1.0.7
#tool nuget:?package=NSCaptcha&version=1.0.7
A .NET library for easy CAPTCHA integration
Features
- Easy Integration: Seamlessly integrate CAPTCHA into your ASP.NET, WPF, or any other .NET project.
 - Customizable: Configure CAPTCHA appearance, difficulty, and behavior to suit your specific needs.
 - High Security: Robust CAPTCHA generation and validation mechanisms to prevent bots and automated attacks.
 - Cross-Platform: Compatible with various .NET platforms and operating systems.
 
License
MIT
Installation
Install via NuGet Package Manager:
- Open the NuGet Package Manager in Visual Studio.
 - Search for "NSCaptcha" in the package manager.
 - Select the "NSCaptcha" package and click "Install."
 - Accept the license agreement (if applicable).
 
Install via .NET CLI:
Open a command prompt or terminal window.
Navigate to your project's directory.
Use the following command:
dotnet add package NSCaptcha
Usage
Refer to the documentation: Detailed usage examples and API documentation are available within the package or on the project website.
Default Configuration
builder.Services.AddDataProtection().SetApplicationName("<Your App Name>").PersistKeysToFileSystem(new DirectoryInfo(Path.Combine("<File Location In System>")));
builder.Services.AddMemoryCache();
captchaBuilder.AddCaptcha(new CaptchaOptions(new TimeSpan(0, 0, 30)))
    .AddCaptchaTokenEncryptionService<DefaultDataProtectionService>()
    .AddCaptchaTokenSerializer<InCookieCaptchaTokenSerializer>()
    .AddCaptchaTokenCacheService<InMemoryCaptchaTokenCacheService>()
    .Build();
After App Build
app.Use(async (context, next) =>
{
    context.Request.EnableBuffering();
    await next();
});
Create Captcha
[Route("api/captcha/create")]
[ApiController]
public class CreationController : ControllerBase
{
    private readonly ICaptchaServices _captchaService;
    public CreationController(ICaptchaServices captchaService)
    {
        _captchaService = captchaService;
    }
    [Route("image")]
    [HttpGet]
    public async Task<FileContentResult> GetImage()
    {
        var captcha = _captchaService.Create();
        return new FileContentResult(captcha.Image, "image/png");
    }
}
Validate Captcha
- Add 
[ValidateCaptcha]attribute top of your validation action method 
    [Route("validate")]
    [HttpPost]
    [ValidateCaptcha]
    public async Task Validate([FromBody] CaptchaTest value)
    {
        
    }
Note:
- Replace 
<File Location In System>with the actual path to store the data protection keys. - You can use another options instead 
PersistKeysToFileSystemto configure the data protection system to persist keys - Notice that your property that you send as captcha value must has "CaptchaValue" name.
 - This is a basic example. You can customize it further based on your specific requirements and preferences.
 
Project Structure
The project follows a well-organized structure:
- Filters: Contains filters for validating CAPTCHA responses.
 - Models: Contains data models used by the library (e.g., 
CaptchaOptions,RandomStringModel). - Services: Contains interfaces and implementations of services related to CAPTCHA (e.g., token generation, caching).
 - Signatures: Contains interfaces for various components of the CAPTCHA system.
 - Utilities: Contains helper classes and methods.
 
Contributing
Contributions are welcome! Please submit pull requests or create issues on the GitHub repository.
| Product | Versions Compatible and additional computed target framework versions. | 
|---|---|
| .NET | 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. 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. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. | 
- 
                                                    
net8.0
- Microsoft.AspNetCore.DataProtection.Extensions (>= 9.0.1)
 - Microsoft.AspNetCore.Http (>= 2.3.0)
 - Microsoft.AspNetCore.Mvc.Core (>= 2.3.0)
 - Microsoft.Extensions.Caching.Memory (>= 9.0.1)
 - SixLabors.ImageSharp.Drawing (>= 2.1.5)
 
 
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.