Giter Site home page Giter Site logo

coolcaptcha's Introduction

logo

CoolCaptcha

Info

CoolCaptcha is a graphic captcha that I think is cool.The library makes it quick and easy to generate base64 data for captcha images, and it can be configured to customize the style to match the style of the product.

languages: 简体中文 English

Case

theme_default_cool theme_default_random

theme1_cool theme1_random

theme2_cool theme2_random

Install

go get github.com/Kuari/coolCaptcha

Usage

Quiuick Start Guide

package main

import (
	"github.com/Kuari/coolCaptcha"
)

func main() {
	imageBase64Data, code, err := coolCaptcha.New().GenerateImage()
}

Custom configuration

package main

import (
	"github.com/Kuari/coolCaptcha"
)

func main() {
	options := []coolCaptcha.Options{
		coolCaptcha.SetBackgroundHexColor("#c4e1f6"),                            // set the background color of the picture
		coolCaptcha.SetFontHexColor("#312E2E"),                                  // set font color
		coolCaptcha.SetLineHexColors([]string{"#f596a1", "#fadeeb", "#f9c975"}), // to set the line color, 3 bars are randomly selected from it, so this parameter sets at least 3 values
		coolCaptcha.SetWidth(300),                                               // set the width of the image
		coolCaptcha.SetHeight(120),                                              // set the height of the image
		coolCaptcha.SetCodeType(coolCaptcha.NumericCharacters),                  // set the type of authentication characters, there are three types: UppercaseEnglishCharacters, NumericCharacters, and MixedCharacters
		coolCaptcha.SetDevMode(true),                                            // Set the development module, which is suitable for saving base64 data as an image during development, so that you can easily view the generated effect
	}

	imageBase64Data, code, err := coolCaptcha.New(options...).GenerateImage()
}

Custom verification codes

You can generate images from a captcha that you generate yourself.

package main

import (
	"github.com/Kuari/coolCaptcha"
)

func main() {
	// The customCode method only supports 4-character English and numbers,
	// when passing in English, it will be capitalized and then used, so when using custom characters, the output code is capitalized, please pay attention when verifying
	// all capitalization is intended to reduce the ambiguity of English letters and numbers
	imageBase64Data, code, err := coolCaptcha.New().CustomCode("cool").GenerateImage()
}

Q&A

1. Can the default font be free for commercial use?

The default font uses blowbrush, which is free for both personal and commercial use.

And custom font settings will be opened in the future, so please stay tuned.

2. Can OCR be cracked?

CoolCaptcha has the risk of being cracked by OCR, please use it in combination with specific scenarios.

3. How to avoid the confusion between English letters and numbers?

CoolCaptcha capitalizes all English, so it is clear between English letters and numbers. You can also use SetCodeType to set the authentication character to be pure English characters or pure numbers.

4. Why was this project developed?

In some specific scenarios, graphics captcha is required, but several problems are found. First of all, most of the current captcha is similar with each other, I think the user experience is very important, designers and front-end hard work products, it will be strange to have a different style of graphic captcha. Secondly, Go's graphics captcha library is a bit small, and I worked with a Java development engineer before, and I envy the ability to quickly output a graphics captcha. Therefore, it is engaged.

coolcaptcha's People

Contributors

hunter-ji avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

coolcaptcha's Issues

setting image dimensions

When setting the dimensions of an image to 90 * 30, the entire image is not displayed. What is the minimum aspect ratio for image to be displayed? Is it possible to scale the image proportionally?

captcha: coolCaptcha.New(
	coolCaptcha.SetWidth(60),                               // set the width of the image
	coolCaptcha.SetHeight(20),                              // set the height of the image
	coolCaptcha.SetCodeType(coolCaptcha.NumericCharacters), // only number captcha
)

imageBase64Data, code, err := a.captcha.Generate()

base64image:

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAAUCAIAAABeYcl+AAACKklEQVR4nMSXy3LTPBSAdY7k+Hcb32qnaaftDxsY2MGWx2DJI/CEvAZLWJXS3BzbsWLn5ovEJAy0hEljxyH5RuOFRueczxpdbOZ/fE/2hwBMTsxEs3zzgjedRLNSRc2RSaQCQAJIggQIISBrVGE1LZMTKzDaA/t6pJ9PND1VtDo2JaksnTHVs6667vPAuow1K6d1X3sHSpWMT+y79sue8z9vOilT/73VFjZK51S5vXx9e/EqNM4LpIe12sK6dKS7X6/f9NxnU7V5JKXtsLHp6PHIs6++3Lwd2DdHWaNVYZ/efRA5ygPs+ZrA8qgEKajIWZHhMU1WIgAE8PdTPnSCJEDUdN4efGv371pep7GY7eGcLmm2VEEJVCLKx36bQmiRO36v5XXOve9GFBLyx8j9SwNKpKu28kMq10puDJTS5L477LpepzXsYFFsGllXGpAgip+WQAVitc0BUliRf+b3naDnDrtKuigTVV0aCKUSmUAqKJU7fESgKKyR3/Luz4L+WdBneVY1QylpAIIrUbpyrVoDpNTHoclDOxzY4cDkAYjKSR7zlDSipI1dRFmemjwweGjw0Ix8gwe0yOtYruf/uwupZEpBFQElFigKoc0SbZqcJvx0MtbjqBlHpxNecy6f5kFan/GL6M6e+wRJ1lAzRV3OMOIvuYLl2bJlaSNdqIuZOp/+N5uo6Zwc/GZiVhI4vP/i/rMdDw9ce2dgv38uh+GYd/jO/AgAAP//UxHzy8onj5EAAAAASUVORK5CYII=

The image is not fully displayed with the specified dimensions.

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.