Coder Social home page Coder Social logo

hei.captcha's Introduction

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

使用

**(0.2.0及以下版本)**开始之前需先把字体文件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;
}

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

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

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

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

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

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

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

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

高级

参照Demo, 通过修改/丰富应用程序运行目录./fonts目录下的字体文件,生成更多不同字体组合的验证码。

(仅在0.2.0及以下版本有效)

License

Hei.Captcha is licensed under the MIT license.

公众号

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

1565148379847

hei.captcha's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.