captcha
Version, currently 0.2.03 versions
- 0.4.0latestJun 6, 2026
- 0.3.0not indexedJun 6, 2026
- 0.2.0not indexedJun 6, 2026
github.com/crystal-china/captcha
Crystal library that generates image CAPTCHAs.
Nothing has been indexed for 0.2.0 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.
Installation
# Add this to your shard.yml
dependencies:
captcha:
github: crystal-china/captcha
version: ~> 0.2.0Then run:
shards installshard.yml
No shard.yml has been indexed for 0.2.0. You can read it on the repository.
Dependencies
Unknown: the shard.yml for this version has not been read yet.
README
This README is the one indexed from the repository at its latest ref, not from the tag for this version.
captcha
Crystal library that generates image CAPTCHAs.

Installation
-
Add the dependency to your
shard.yml:dependencies: captcha: github: crystal-china/captcha -
Run
shards install
Usage
require "captcha"
captcha = CaptchaGenerator.new(length: 6)
# Return image as base64 string.
captcha.base64
# An <img> tag string that embeds the image for use in an HTML page.
captcha.img_tag # <img src="data:image/webp;base64,BASE64_ENCODED_IMAGE_DATA" />
# You can set image height or width like this:
captcha.img_tag(height: "50px", width: "100px")
# You can use #write_html_file to preview how the captcha looks in an HTML file.
captcha.write_html_file("test.html")
# return the underlying captcha code
captcha.code # nh8S8G
More usage, check spec
You should use this shard with a memory cache.
Refer to the links below for a production use case with Lucky.
create a cache.
Generate a random unique signup_captcha_id and save to cookie.
Then use this random id as key, save the captcha code into cache and render the img_tag
get the captcha code from cache use cookie.
Get the captcha_id from the cookie, then retrieve the captcha code from the cache and compare them.
src/actions/sign_ups/create.cr
limit
You can't create a fully static Crystal binary because it relies on libvips as a dependency. If that’s an issue for you, you might want to check out simple_captcha.
These two libraries should work interchangeably, so you shouldn’t need to change your code.
Contributing
- Fork it (https://github.com/crystal-china/captcha/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Contributors
- Ali Naqvi creator and maintainer
- Billy.Zheng - maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.2.0- Tagged
- Jun 6, 2026
- Commit
deb7c77dfb55- Indexed
- not yet
Dependents
Repository
github.com/crystal-china/captcha
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 14, 2026
- Synced
- Aug 14, 2026
- Versions
- 3