Download the PHP package slushie/recaptcha-secure-token without Composer

On this page you can find all versions of the php package slushie/recaptcha-secure-token. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package recaptcha-secure-token

ReCaptcha Secure Token

This library provides a PHP implementation of the ReCaptcha v2 Secure Token algorithm.

Usage

You should add this library to your composer require section:

"require": {
  "slushie/recaptcha-secure-token": "~1.0",
  /* ... */
}

From within your PHP code, you can create an instance of the ReCaptchaToken class and pass in your site_key and site_secret values:

$config = ['site_key' => 'YOUR_SITE_KEY', 'site_secret' => 'YOUR_SITE_SECRET'];
$recaptchaToken = new \ReCaptchaSecureToken\ReCaptchaToken($config);

To generate a secure token you must provide a unique session_id:

$sessionId = uniqid('recaptcha');
$secureToken = $recaptchaToken->secureToken($sessionId);

Finally, use this token value in your HTML output. For example:

<div class="g-recaptcha" 
     data-sitekey="YOUR_SITE_KEY"
     data-stoken=""></div>

Timestamp

Being a time-based protocol, the timestamp must be accurate. If your system clock is not accurate (try ntpdate), you must pass an accurate timestamp (in ms) to secureToken. You can obtain one from an NTP server, e.g.:

$socket = new Bt51\NPM\Socket('0.pool.ntp.org', 123);
$ntp_client = new Bt51\NPM\Client($socket);
$timestamp = $ntp_client->getTime()->getTimestamp() * 1000;

$sessionId = uniqid('recaptcha');
$secureToken = $recaptchaToken->secureToken($sessionId, $timestamp);

Algorithm Implementation

The original ReCaptcha algorithm is undocumented, although example source code is provided in Java.

This implementation is based on the original Java implementation, as well as some resources from around the web. Of important note are the follow:

For more implementation details, please see the source code.

Security Considerations

There are multiple security flaws in the original implementation. Of particular note is the use of the ECB block mode, which is known to be insecure. A simple example of this insecurity is available on the Wikipedia article on Block cipher modes.

This could theoretically lead to spammers acquiring your site_secret. No workaround is provided, the secure token algorithm is inherently insecure.

License and Copyright

This code is Copyright 2015, Josh Leder. The original Java implementation is Copyright 2014, Google Inc.

This code is provided under the Apache 2.0 license.


All versions of recaptcha-secure-token with dependencies

PHP Build Version
Package Version
Requires php Version >= 5.3.3
ext-mcrypt Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package slushie/recaptcha-secure-token contains the following files

Loading the files please wait ....