blackcube / lockbot
PHP version of Lockbot Captcha
1.0.0
2025-08-28 09:59 UTC
Requires
- php: ~8.3.0
- ext-mbstring: *
Requires (Dev)
This package is not auto-updated.
Last update: 2025-08-29 08:49:03 UTC
README
Installation
If you use Packagist for installing packages, then you can update your composer.json like this :
{ "require": { "blackcube/lockbot": "*" } }
Testing
To run the tests:
composer install ./vendor/bin/codecept build ./vendor/bin/codecept run
To check coverage report:
./vendor/bin/codecept run --coverage --coverage-html
Usage
Captcha class allows you to generate and verify POW CAPTCHA codes.
Generating CAPTCHA Codes
use blackcube\lockbot\Captcha; $captcha = new Captcha(); $challenge = $captcha->generateChallenge(); // Generate a CAPTCHA challenge // $challenge is an array with 'algorithm' and 'salt' and 'hash' keys // ['algorithm' => 'sha256', 'salt' => 'random_salt', 'hash' => 'computed_hash']
Verifying CAPTCHA Codes
// $solution is the solution provided by the user ['salt' => 'challenge_salt', 'hash' => 'challenge_hash', 'algorithm' => 'challenge_algorithm', 'solution' => 'user_solution'] use blackcube\lockbot\Captcha; $captcha = new Captcha( algorithm: $solution['algorithm'] // Use the same algorithm as the challenge); ); $isValid = $captcha->verifySolution($solution['salt'], $solution['hash'], $solution['solution']); // Verify the provided solution
Main methods are:
- Generate a CAPTCHA challenge
generateChallenge(): array
- Verify a provided solution
verifySolution(string $salt, string $hash, string $solution): bool
Contributing
All code contributions - including those of people having commit access - must go through a pull request and approved by a core developer before being merged. This is to ensure proper review of all the code.
Fork the project, create a feature branch , and send us a pull request.