Captcha-Stateless
view release on metacpan or search on metacpan
}
},
"configure" : {
"requires" : {
"ExtUtils::MakeMaker" : "0"
}
},
"runtime" : {
"requires" : {
"Crypt::Blowfish" : "2.14",
"Crypt::CBC" : "2.33"
}
}
},
"release_status" : "stable",
"version" : "0.04",
"x_serialization_backend" : "JSON::PP version 2.27300_01"
}
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: '1.4'
name: Captcha-Stateless
no_index:
directory:
- t
- inc
requires:
Crypt::Blowfish: '2.14'
Crypt::CBC: '2.33'
version: '0.04'
x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
Makefile.PL view on Meta::CPAN
use ExtUtils::MakeMaker;
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
WriteMakefile(
'NAME' => 'Captcha::Stateless',
'VERSION_FROM' => 'Stateless.pm', # finds $VERSION
'PREREQ_PM' => {Crypt::CBC => 2.33, Crypt::Blowfish => 2.14}, # e.g., Module::Name => 1.1
($] >= 5.005 ? ## Add these new keywords supported since 5.005
(ABSTRACT => 'A stateless captcha implementation that stores state in an HTTP cookie in the browser.',
AUTHOR => 'Martin Schmitt <mas at scsy dot de>') : ()),
);
Stateless.pm view on Meta::CPAN
package Captcha::Stateless;
use strict;
use warnings;
use GD::SecurityImage;
use Crypt::CBC;
require Exporter;
our @ISA = qw(Exporter);
our @EXPORT_OK = qw();
our $VERSION = '0.04';
sub new{
my $class = shift;
my %parameters = (
Stateless.pm view on Meta::CPAN
sub error {
my $self = shift;
return $self->{'error'};
}
sub encrypt {
my $self = shift;
my $captchavalue = shift;
my $expire = time + $self->{'expire'};
my $key = _slurp_keyfile($self->{'keyfile'});
my $cipher = Crypt::CBC->new(
-key => $key,
-cipher => 'Blowfish'
);
return $cipher->encrypt_hex("$captchavalue:$expire");
}
sub validate {
my $self = shift;
my %parameters = (
@_,
);
my $cookie = $parameters{'cookie'};
my $entered = $parameters{'entered'};
my $key = _slurp_keyfile($self->{'keyfile'});
my $cipher = Crypt::CBC->new(
-key => $key,
-cipher => 'Blowfish'
);
my $decrypted = $cipher->decrypt_hex($cookie);
my ($captchavalue, $expire) = split /:/,$decrypted;
if ($expire < time){
$self->{'error'} = 'Captcha expired.';
return 0;
}
if ($captchavalue eq $entered){
Stateless.pm view on Meta::CPAN
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
=head1 Dependencies
=head2 Core
L<perl>, L<Crypt::CBC>, L<Crypt::Blowfish>
=head2 Recommended
L<GD::SecurityImage>, L<CGI>
=cut
( run in 1.188 second using v1.01-cache-2.11-cpan-e1769b4cff6 )