Authen-Captcha

 view release on metacpan or  search on metacpan

Captcha.pm  view on Meta::CPAN


  my $captcha = Authen::Captcha->new(
    data_folder => '/some/folder',
    output_folder => '/some/http/folder',
    );

  # create a captcha. Image filename is "$token.png"
  my $token = $captcha->generate_code($number_of_characters);

  # check for a valid submitted captcha
  #   $code is the submitted letter combination guess from the user
  #   $token is the submitted token from the user (that we gave them)
  my $results = $captcha->check_code($code,$token);
  # $results will be one of:
  #          1 : Passed
  #          0 : Code not checked (file error)
  #         -1 : Failed: code expired
  #         -2 : Failed: invalid code (not in database)
  #         -3 : Failed: invalid code (code does not match token)
  ##############

Captcha.pm  view on Meta::CPAN


It can also be called in array context to retrieve the string of characters used to generate the captcha (the string the user is expected to respond with). This is useful for debugging.
ex.

C<($token,$chars) = $captcha-E<gt>generate_code( $number_of_characters );>

=item C<$results = $captcha-E<gt>check_code($code,$token);>

check for a valid submitted captcha

$code is the submitted letter combination guess from the user

$token is the submitted token from the user (that we gave them)

If the $code and $token are correct, the image file and database entry will be removed.

If the $token matches one in the database, and "keep_failures" is false (the default), the image file and database entry will be removed to avoid repeated attempts on the same captcha.

$results will be one of:

    1 : Passed

README  view on Meta::CPAN


      my $captcha = Authen::Captcha->new(
        data_folder => '/some/folder',
        output_folder => '/some/http/folder',
        );

      # create a captcha. Image filename is "$md5sum.png"
      my $md5sum = $captcha->generate_code($number_of_characters);

      # check for a valid submitted captcha
      #   $code is the submitted letter combination guess from the user
      #   $md5sum is the submitted md5sum from the user (that we gave them)
      my $results = $captcha->check_code($code,$md5sum);
      # $results will be one of:
      #          1 : Passed
      #          0 : Code not checked (file error)
      #         -1 : Failed: code expired
      #         -2 : Failed: invalid code (not in database)
      #         -3 : Failed: invalid code (code does not match crypt)
      ##############

README  view on Meta::CPAN


        It can also be called in array context to retrieve the string of
        characters used to generate the captcha (the string the user is
        expected to respond with). This is useful for debugging. ex.

        "($md5sum,$chars) = $captcha->generate_code( $number_of_characters
        );"

    "$results = $captcha->check_code($code,$md5sum);"
        check for a valid submitted captcha $code is the submitted letter
        combination guess from the user $md5sum is the submitted md5sum from
        the user (that we gave them) $results will be one of:

            1 : Passed
            0 : Code not checked (file error)
           -1 : Failed: code expired
           -2 : Failed: invalid code (not in database)
           -3 : Failed: invalid code (code does not match crypt)

  ACCESSOR METHODS



( run in 0.833 second using v1.01-cache-2.11-cpan-702932259ff )