Socket
Book a DemoInstallSign in
Socket

fastcaptcha

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fastcaptcha

0.2.3
bundlerRubygems
Version published
Maintainers
1
Created
Source

fastcaptcha is another image captcha solution. It's simple and very fast.

INSTALL:

sudo gem install fastcaptcha

REQUIREMENT:

  • ruby >= 1.9.1
  • ruby development libraries (debian: ruby1.9.1-dev)
  • opencv >= 2.1.0 development libraries (debian: libcv-dev libhighgui-dev)

USAGE:

require 'fastcaptcha' captcha = FastCaptcha.new # defaults to redis for caching and low complexity captchas. challenge = captcha.generate puts challenge.key puts challenge.image # PNG image data

require 'fastcaptcha' require 'moneta/memcache' captcha = FastCaptcha.new(Moneta::Memcache.new, 3) # use memcached instead & level 3 complexity challenge = captcha.generate puts challenge.key puts challenge.image # PNG image data

SINATRA HELPER:

  • This adds a simple sinatra helper to display and validate captcha. Uses JQuery, so tough luck if you're using another Javascript library (patches welcome). If you're not using sinatra, you should be.

Add the sinatra helper to your application:

require 'sinatra/captcha' class MyApp < Sinatra::Base # ttl of captcha before user has to respond. set :captcha_ttl, 30

# complexity 1 is simple, 4 is wicked hard (makes segmentation very difficult).
set :captcha_level, 2

# use memcached instead of redis (default).
# set :captcha_cache, Moneta::Memcache

register Sinatra::Captcha

end

Add the captcha to your form using the captcha helper:

captcha(ajax: true, id: 'captcha_div')

Validate the captcha on form submission:

if captcha_correct? do_something else do_something_else end

You can have multiple captchas in the same page within different

elements. Just make sure captcha element ids are unique.

LICENSE:

GNU GPLv3, so its free and comes with no guarantees. If it brings down your website or burns down your house, I will not be held responsible. Use it at your own risk. You can read all about GNU here: http://www.gnu.org and GNU GPLv3 here: http://www.gnu.org/licenses/gpl.txt.

FAQs

Package last updated on 21 Sep 2011

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.