Hei.Captcha

by gebiWangshushu

gebiWangshushu /Hei.Captcha

一个跨平台的图形验证码生成工具包/.net core

151 Stars 34 Forks Last release: Not found MIT License 11 Commits 0 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

Hei.Captcha

Hei.Captcha

.net core,跨平台的验证码生成工具包,支持动态gif验证码。基于ImageSharp

使用.NET Standard 2.0,目前仅测试过.net core的支持,.net frameword 4.6.1 及以上请自行测试~

中文泡泡验证码

img

1564563919705

1564563740706

字母数字组合验证码

img

1564563801717

1564563816361

1564563853298

1564563877047

动态gif中文泡泡验证码

动态gif字母数字组合验证码

表单示例

1565146764062

使用

开始之前先把字体文件https://github.com/gebiWangshushu/Hei.Captcha/tree/master/Demo/fonts整个fonts目录下载放到程序根目录(如果只想下载一个文件夹可以使用chrome插件:GitZip for github)

Install-Package Hei.Captcha
//StartUp.cs,Method ConfigureServices()
services.AddHeiCaptcha();
private readonly SecurityCodeHelper _securityCode;

public HomeController(SecurityCodeHelper securityCode) { this._securityCode = securityCode; }

///

/// 泡泡中文验证码 /// /// public IActionResult BubbleCode() { var code = _securityCode.GetRandomCnText(2); var imgbyte = _securityCode.GetBubbleCodeByte(code);

return File(imgbyte, "image/png");

}

///

/// 数字字母组合验证码 /// /// public IActionResult HybridCode() { var code = _securityCode.GetRandomEnDigitalText(4); var imgbyte = _securityCode.GetEnDigitalCodeByte(code);

return File(imgbyte, "image/png");

}

///

/// gif泡泡中文验证码 /// /// public IActionResult GifBubbleCode() { var code = _securityCode.GetRandomCnText(2); var imgbyte = _securityCode.GetGifBubbleCodeByte(code);

return File(imgbyte, "image/gif");

}

///

/// gif数字字母组合验证码 /// /// public IActionResult GifHybridCode() { var code = _securityCode.GetRandomEnDigitalText(4); var imgbyte = _securityCode.GetGifEnDigitalCodeByte(code);

return File(imgbyte, "image/gif");

}

高级

参照Demo, 通过修改/丰富应用程序运行目录

./fonts
目录下的字体文件,生成更多不同字体组合的验证码。

公众号

欢迎关注我的公众号。虽然有点懒,不过偶尔打打鸡血还是会写点东西的,你的关注就是我的动力,谢谢支持~~

1565148379847

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.