CAPTCHA
About
According to wikipedia, a CAPTCHA (a contrived acronym for "Completely Automated Public Turing test to tell Computers and Humans Apart") is a type of challenge–response test used in computing to determine whether or not the user is human.
The component TCaptchaLabel allows to create a CAPTCHA to be used on any LCL form. It displays random characters which are colored and rotated and overlayed by colored lines to impede machine detection of the CAPTCHA text.
Author
Werner Pamler
License
Modified LGPL (with linking exception), like Lazarus LCL. See the file COPYING.modifiedLGPL.txt, included in the Lazarus distribution, for details about the license.
Description
TCaptchaLabel descends from TGraphicControl and contains its own drawing routine. Just place it on the form and use it. It displays a random string with rotated characters and overlaid lines.
Methods
function`` Verify(``const`` AText: String): Boolean- Compares whether the user-provided stringATextmatches the CAPTCHA string and returnstruein case of an agreement, orfalseotherwise.procedure`` NewCaptcha- Generates and displays a new CAPTCHA string
Properties
Text: String- CAPTCHA string. The characters of the string are selected randomly from theUpperCaseChars,LowerCaseChars,NumericCharsand/orCustomChars.NumChars: Integer- Number of characters in the CAPTCHA, i.e. length ofTextNumLines: Integer- Number of lines drawn over the CAPTCHAFont1, Font2: TFont- Two fonts to be mixed within the CAPTCHA characters randomlyMaxAngle: Integer- Maximum rotation angle (in degrees) for the characters which are rotated by a random angle between-MaxAngleand+MaxAngleColor: TColor- Background color of the area of the control covered by the CAPTCHA. Character and line colors are selected such that a minimum brightness difference to the background color is achieved.UpperCaseChars: String- Contains the characters among which upper-case characters in the CAPTCHA are selected randomly. UTF8 encoding is supported as usual (and like for the following strings)LowerCaseChars: String- Contains the characters among which lower-case characters in the CAPTCHA are selected randomlyNumericChars: String- Contains the numeric characters characters for the CAPTCHACustomChars: String- Contains non-alpha and non-numeric characters for the CAPTCHAOptions: TCaptchaOptions- This is a set of the following enumerated options which can be combined:coAlphaUpper- Use upper-case characters as defined by the theUppercaseCharsstring
Note: The characters which are hard to distinguish are skipped, O (upper-case o) vs 0 (zero), l (lower-case L) vs I (upper-case I)coAlphaLower- Use lower-case characters as defined by theLowercaseCharsstringcoNumeric- Use numeric characters as defined by theNumericCharsstringcoCustom- Use special characters as defined by theCustomCharsstringcoRotated- Characters are rotatedcoFont1- Font1 is usedcoFont2- Font2 is usedcoLines- Lines are drawn over the CAPTCHA
NewCaptchaEvent: TNewCaptchaEvent- Enumerated property which determines a short-cut how to create a new CAPTCHA string at runtime:nceNone- Feature is deactivated; CAPTCHA can only be changed by code.nceClick- A new CAPTCHA is created when the user clicks on the controlnceDblClick- A new CAPTCHA is created when the user double-clicks on the control.
Installation
Development version
The development version (aka trunk) is available at https://sourceforge.net/p/lazarus-ccr/svn/HEAD/tree/components/captcha/. Download the package using svn or get the zipped snapshot version.
Load the package file captcha_pkg.lpk into the Lazarus Package Editor and click "Use" > "Install" to rebuild the Lazarus IDE. When Lazarus restarts you find the new component in the palette "Misc".
Release version
The stable release version is distributed via the Online-Package-Manager (OPM): Check the item "Captcha" in the OPM list, click "Install" and confirm the prompt to rebuild the IDE.
From the Free Pascal wiki, page "CAPTCHA", as it stood on 2021-10-01 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.
Talk about this page
Nobody has opened a bench for this page yet. Sign in to open one.
