Generate captcha images based on ImageSharp and .NET.
基于ImageSharp项目和.NET,生成图形验证码。
Name | Description | NugetPackage |
---|---|---|
CaptchaN | Core module | |
CaptchaN.DI.Microsoft | DI module for default container |
The following is main codes for basic usage.
// Load or install fonts(*.ttf) which are provided by yourself
IFontRandomerFactory fontRandomerFactory = new ...;
IFontRandomer fontRandomer = fontRandomerFactory.CreateFontRandomer();
// Init color randomer
IColorRandomer colorRandomer = new ...;
IPainter painter = new Painter(fontRandomer, colorRandomer);
// Init the content settings for images
PainterOption painterOption = new(){...};
// Optional. Generate random text for solid length
ICodeTextGenerator codeTextGenerator = new ...;
string codeText = codeTextGenerator.Generate(4);
// Generate an image
await painter.GenerateImageAsync(codeText, painterOption);
Please see Wiki and Samples for details.
Issues and pull requests are welcomed if you have any questions!
如果您有任何疑问,欢迎提交Issue和PR!