https://github.com/leafrock/captchan
Generate captcha images based on .NET
https://github.com/leafrock/captchan
Last synced: 3 months ago
JSON representation
Generate captcha images based on .NET
- Host: GitHub
- URL: https://github.com/leafrock/captchan
- Owner: LeaFrock
- License: mit
- Created: 2021-04-08T13:17:21.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-11-18T19:52:40.000Z (almost 2 years ago)
- Last Synced: 2024-04-26T22:02:42.172Z (over 1 year ago)
- Language: C#
- Size: 49.8 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CaptchaN
[DotNetUrl]: https://dotnet.microsoft.com/download
[ImageSharpUrl]: https://github.com/SixLabors/ImageSharp
[CaptchaN-SvgUrl]: https://img.shields.io/nuget/v/CaptchaN.svg
[CaptchaN-NugetUrl]: https://www.nuget.org/packages/CaptchaN
[CaptchaN-DI-Microsoft-SvgUrl]: https://img.shields.io/nuget/v/CaptchaN.DI.Microsoft.svg
[CaptchaN-DI-Microsoft-NugetUrl]: https://www.nuget.org/packages/CaptchaN.DI.Microsoft
Generate captcha images based on [ImageSharp][ImageSharpUrl] and .NET.
>基于[ImageSharp][ImageSharpUrl]项目和.NET,生成图形验证码。[][DotNetUrl]
## Packages |Nuget包
| Name | Description | NugetPackage |
| :-------------------: | :-----------------------------: | :--------------------------------------------------------------------------------------: |
| CaptchaN | Core module | [![CaptchaN][CaptchaN-SvgUrl]][CaptchaN-NugetUrl] |
| CaptchaN.DI.Microsoft | DI module for default container | [![CaptchaN.DI.Microsoft][CaptchaN-DI-Microsoft-SvgUrl]][CaptchaN-DI-Microsoft-NugetUrl] |## QuickStart |快速入门
The following is main codes for basic usage.
``` C#
// 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](https://github.com/LeaFrock/CaptchaN/wiki) and [Samples](https://github.com/LeaFrock/CaptchaN/tree/main/Samples) for details.
## Contribution |贡献
Issues and pull requests are welcomed if you have any questions!
>如果您有任何疑问,欢迎提交Issue和PR!