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
go get github.com/Kuari/coolCaptcha
package main
import (
"github.com/Kuari/coolCaptcha"
)
func main() {
imageBase64Data, code, err := coolCaptcha.New().GenerateImage()
}
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()
}
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()
}
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.
CoolCaptcha
has the risk of being cracked by OCR, please use it in combination with specific scenarios.
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.
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.