A minimalistic and performant CAPTCHA generator and validator, with customizable rendering options ready for both web and desktop applications. The image manipulation is done through https://github.com/ajmas/JH-Labs-Java-Image-Filters.
CAPTCHAs generated by flexcaptcha are highly customizable and can be generated and validated in different ways through the same application simultaneously. Thanks to this, flexcaptcha can be used as a centralized service for your web application landscape, or as a microservice, to hand out and validate CAPTCHAs that are tailored to each individual application that uses it.
The generated image data and tokens are not permanently stored in a database, improving response times and ease of use in your application besides not requiring additional infrastructure to set up.
Usage
text-based CAPTCHA:
SimpleCaptchaTextGenerator generator = new SimpleCaptchaTextGenerator(); //Can generate randomized strings from a pool of allowed characters
String s = generator.generate(10, Case.UPPERCASE); //Here is my random string. I want all letters to be uppercase. lowercase and mixed-case is supported, too. Or you supply your own string.
String pw = "ThisIsMyPassword"; //Supply a password for encryption
SimpleTextImageRenderer renderer = new SimpleTextImageRenderer(); //pick a renderer controlling the image generation (and distortion)
CipherHandler ch = new CipherHandler(); //Cipherhandler for implementing the encryption and decryption
TextCaptchaHandler handler = new SimpleTextCaptchaHandler();
String saltSource = "Hello World!"; //A salt source for salting the hashes and encryption
TextCaptcha captcha = handler.toCaptcha(s, ch, saltSource, pw, renderer , 100, 300); //putting it all together
Sample images:
image-based CAPTCHA:
ImageCaptchaHandler handler = new SimpleImageCaptchaHandler();
CipherHandler ch = new CipherHandler();
ImageLoader loader = new ImageLoader();
BufferedImage[] solutionImages = loader.getImagesfromPath("C:\\SomeDirectory");
BufferedImage[] fillImages = loader.getImagesfromPath("C:\\SomeOtherDirectory");
String saltSource = "Hello World!";
int gridWidth = 3;
ImageCaptcha captcha = handler.generate(gridWidth, ch, saltSource, password, solutionImages, fillImages);
Dependency
<dependency>
<groupId>io.github.yaforster</groupId>
<artifactId>flexcaptcha</artifactId>
<version>1.0.1</version>
</dependency>