Documentation
¶
Overview ¶
Package captcha provides an easy to use
Index ¶
Constants ¶
View Source
const ( MathOperatorPlus mathOperator = "+" MathOperatorMinus mathOperator = "-" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type OptionMath ¶
type OptionMath struct { // The width of the SVG captcha // Default: 150 Width uint16 // The height of the SVG captcha // Default: 50 Height uint16 // The font size in the captcha // Default: 16 FontSize uint8 // Path font FontPath string // The color of the characters in the captcha. // True: the characters will have individual colors. // False: The characters will be gray // Default: false IsColor bool // Invert the colors. // Default: false IsInverse bool // The number of lines in the captcha // Default: 1 Curve uint8 // Background color of the SVG captcha // Default: Transperant BackgroundColor color.Color // The operation for the mathematical calculation // Supports addition (+) and subtraction (-) operations // If there's no specified operation, it will automatically choose one. MathOperator mathOperator // The minimum value for a number in the operation // Default: 1 MathMin uint8 // The maximum value for a number in the operation. // Default: 9 MathMax uint16 }
type OptionText ¶
type OptionText struct { // The length of the random string // Default: 4 Size uint8 // The width of the SVG captcha // Default: 150 Width uint16 // The height of the SVG captcha // Default: 50 Height uint16 // The font size in the captcha // Default: 16 FontSize uint8 // The color of the characters in the captcha. // True: the characters will have individual colors. // False: The characters will be gray // Default: false IsColor bool // Invert the colors. // Default: false IsInverse bool // The number of lines in the captcha // Default: 1 Curve uint8 // Background color of the SVG captcha // Default: Transperant BackgroundColor color.Color // Remove unacceptable characters from the captcha. IgnoreCharacters string // Path font FontPath string // The characters that can be displayed in the captcha. // Default: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 CharactersPreset string // Generate With Text // Note: Text is optional. If not provided, it will be generated randomly Text string }
type Result ¶
type Result struct { // A random string or the result of an operation. Text string // The HTML code snippet for SVG. Data string }
func CreateByMath ¶
func CreateByMath(option OptionMath) (*Result, error)
CreateByMath: Generate a new captcha. It will return a captcha with an operation like 1 + 1.
func CreateByText ¶
func CreateByText(option OptionText) (*Result, error)
CreateByText: generate a new captcha
Source Files
¶
Click to show internal directories.
Click to hide internal directories.