YMJake.FusionCaptcha.Storage.Redis
1.0.0
See the version list below for details.
dotnet add package YMJake.FusionCaptcha.Storage.Redis --version 1.0.0
NuGet\Install-Package YMJake.FusionCaptcha.Storage.Redis -Version 1.0.0
<PackageReference Include="YMJake.FusionCaptcha.Storage.Redis" Version="1.0.0" />
<PackageVersion Include="YMJake.FusionCaptcha.Storage.Redis" Version="1.0.0" />
<PackageReference Include="YMJake.FusionCaptcha.Storage.Redis" />
paket add YMJake.FusionCaptcha.Storage.Redis --version 1.0.0
#r "nuget: YMJake.FusionCaptcha.Storage.Redis, 1.0.0"
#:package YMJake.FusionCaptcha.Storage.Redis@1.0.0
#addin nuget:?package=YMJake.FusionCaptcha.Storage.Redis&version=1.0.0
#tool nuget:?package=YMJake.FusionCaptcha.Storage.Redis&version=1.0.0
FusionCaptcha
FusionCaptcha is a .NET captcha toolkit built on top of the Vello rendering pipeline. It focuses on three core responsibilities—code generation, image rendering, and persistence—while leaving fonts, backgrounds, and other resources entirely in the hands of your application. This keeps the library lightweight and easy to integrate into Web API, Minimal API, or background services.
Packages
| Package | Description |
|---|---|
YMJake.FusionCaptcha.Abstractions |
Core contracts (ICaptcha, ICaptchaRenderer, IStorage, CaptchaOptions, etc.). |
YMJake.FusionCaptcha.Core |
Default pipeline (background → text → noise → distortion), Vello renderer, font/background providers, DI extensions. |
YMJake.FusionCaptcha.Storage.Memory |
IMemoryCache-based storage provider. |
YMJake.FusionCaptcha.Storage.Redis |
StackExchange.Redis-based storage provider with async APIs. |
samples/YMJake.CaptchaSharp.MinimalApi |
Minimal API sample demonstrating DI wiring and Swagger testing. |
Installation
dotnet add package YMJake.FusionCaptcha.Core
dotnet add package YMJake.FusionCaptcha.Storage.Memory
# or
dotnet add package YMJake.FusionCaptcha.Storage.Redis
Vello’s native dependencies (
vello_ffi.dll, etc.) are shipped transitively via NuGet. Ensure your runtime RID is supported by Vello.
Quick Start (ASP.NET Core)
using YMJake.CaptchaSharp.Abstractions;
using YMJake.CaptchaSharp.Core;
using YMJake.CaptchaSharp.Storage.Memory;
var builder = WebApplication.CreateBuilder(args);
builder.Services
.AddCaptcha(options =>
{
options.Image.Width = 160;
options.Image.Height = 60;
options.Image.FontSize = 36;
options.Image.FontFamily = "ActionJ";
options.Image.BackgroundImage = "Grid";
})
.UseFileResources(resources =>
{
resources.Fonts.BasePath = Path.Combine(builder.Environment.ContentRootPath, "Resources", "Fonts");
resources.Fonts.AddFont("actionj.ttf", "ActionJ");
resources.Backgrounds.BasePath = Path.Combine(builder.Environment.ContentRootPath, "Resources", "Backgrounds");
resources.Backgrounds.AddBackground("grid.png", "Grid");
})
.UseVelloRenderer()
.UseCaptchaMemoryStorage();
var app = builder.Build();
app.MapGet("/captcha", async (string id, ICaptcha captcha) =>
{
var result = await captcha.GenerateAsync(id);
return Results.File(result.Bytes, result.ContentType);
});
app.MapGet("/captcha/validate", (string id, string code, ICaptcha captcha) =>
{
var success = captcha.Validate(id, code);
return Results.Ok(new { id, code, success });
});
app.Run();
Resource Management
- Fonts – Inject via
IFontProvider.UseFileResources/UseFileFontOptionsloads fonts from disk and exposes them throughoptions.Image.FontFamily. - Backgrounds – Provided by
IBackgroundProvider. The default is a solid color, but you can register multiple background images and pick one viaoptions.Image.BackgroundImage. - Pipeline Steps –
BackgroundStep,TextStep,NoiseStep,DistortionStepall implementICaptchaPipelineStep. You can replace or extend them with custom steps.
Storage Options
UseCaptchaMemoryStorage()– UsesIMemoryCache, ideal for single-node deployments or tests.UseCaptchaRedisStorage(options => { ... })– Backs captcha storage with Redis; configure connection string, database index, key prefix, etc.
Feature Highlights
- Pure managed rendering pipeline powered by Vello + ImageSharp (PNG output by default).
- Fonts/backgrounds are provided by the host application; the library ships without embedded assets.
- DI-friendly configuration:
.AddCaptcha().UseVelloRenderer().UseCaptchaMemoryStorage(). - Memory and Redis storage providers with async validation APIs.
- Minimal API sample with Swagger ready to debug.
Roadmap
- Additional captcha types: Chinese, arithmetic, slider, animated variants.
- Pluggable pipeline DSL similar to
QrBuilder. - GIF / WebP / ImageSharp encoders.
- Storage-level TTL strategies and hit stats for custom rate limiting.
Contributions and feature requests are always welcome!
| 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.Extensions.DependencyInjection.Abstractions (>= 9.0.0)
- StackExchange.Redis (>= 2.10.1)
- YMJake.FusionCaptcha.Abstractions (>= 1.0.0)
- YMJake.FusionCaptcha.Core (>= 1.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.