Project

racaptcha

0.0
Low commit activity in last 3 years
No release in over a year
This is a Captcha gem for ruby. It drawing captcha image with C code so it no dependencies.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

 Project Readme

Racaptcha

This is a Captcha gem for ruby. It drawing captcha image with C code so it no dependencies.

If you want to use it in Rails, you can use rucaptcha gem.

If you only want to use in the API, then this gem is exactly what you need.

Installation

Add this line to your application's Gemfile:

gem 'racaptcha'

And then execute:

$ bundle

Or install it yourself as:

$ gem install racaptcha

Usage

Create config/initializers/racaptcha.rb

RaCaptcha.setup do |config|
  # Store Captcha code where, this config more like Rails config.cache_store
  # Default :file_store
  config.cache_store = [:file_store, 'tmp/cache/racaptcha/session']
  # racaptcha expire time, default 2 minutes
  config.expires_in = 2.minutes
  # Color style, default: :colorful, allows: [:colorful, :black_white]
  config.style = :colorful
  # Chars length: default 5, allows: [3..7]
  config.length = 5
  # enable/disable Strikethrough. default: true
  config.strikethrough = true
  # enable/disable Outline style, default: false
  config.outline = false
end
# generate captcha without cache
code, raw_data = RaCaptcha.generate

# generate captcha with cache
token, code, raw_data = RaCaptcha.generate_captcha

# verify captcha when using cache
RaCaptcha.verify_racaptcha?(cache_key: token, captcha: code)

# not delete cache when verify captcha
RaCaptcha.verify_racaptcha?(cache_key: token, captcha: code, keep_cache: true)

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Racaptcha project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.