Download the PHP package altcha-org/altcha without Composer
On this page you can find all versions of the php package altcha-org/altcha. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package altcha
ALTCHA PHP Library
The ALTCHA PHP Library is a lightweight, zero-dependency library designed for creating and verifying ALTCHA challenges, specifically tailored for PHP applications.
Compatibility
This library is compatible with:
- PHP 7.4+
- All major platforms (Linux, Windows, macOS)
Example
Installation
To install the ALTCHA PHP Library, use the following command:
Usage
Here’s a basic example of how to use the ALTCHA PHP Library:
API
Altcha::createChallenge(array $options): array
Creates a new challenge for ALTCHA.
Parameters:
options array
:algorithm string
: Hashing algorithm to use (SHA-1
,SHA-256
,SHA-512
, default:SHA-256
).maxNumber int
: Maximum number for the random number generator (default: 1,000,000).saltLength int
: Length of the random salt (default: 12 bytes).hmacKey string
: Required HMAC key.salt string
: Optional salt string. If not provided, a random salt will be generated.number int
: Optional specific number to use. If not provided, a random number will be generated.expires \DateTime
: Optional expiration time for the challenge.params array
: Optional URL-encoded query parameters.
Returns: array
Altcha::verifySolution(array $payload, string $hmacKey, bool $checkExpires): bool
Verifies an ALTCHA solution.
Parameters:
payload array
: The solution payload to verify.hmacKey string
: The HMAC key used for verification.checkExpires bool
: Whether to check if the challenge has expired.
Returns: bool
Altcha::extractParams(array $payload): array
Extracts URL parameters from the payload's salt.
Parameters:
payload array
: The payload containing the salt.
Returns: array
Altcha::verifyFieldsHash(array $formData, array $fields, string $fieldsHash, string $algorithm): bool
Verifies the hash of form fields.
Parameters:
formData array
: The form data to hash.fields array
: The fields to include in the hash.fieldsHash string
: The expected hash value.algorithm string
: Hashing algorithm (SHA-1
,SHA-256
,SHA-512
).
Returns: bool
Altcha::verifyServerSignature($payload, string $hmacKey): array
Verifies the server signature.
Parameters:
payload mixed
: The payload to verify (string orServerSignaturePayload
array).hmacKey string
: The HMAC key used for verification.
Returns: array
Altcha::solveChallenge(string $challenge, string $salt, string $algorithm, int $max, int $start, $stopChan = null): array
Finds a solution to the given challenge.
Parameters:
challenge string
: The challenge hash.salt string
: The challenge salt.algorithm string
: Hashing algorithm (SHA-1
,SHA-256
,SHA-512
).max int
: Maximum number to iterate to.start int
: Starting number.
Returns: array
Tests
License
MIT