### Installation Source: https://github.com/altcha-org/altcha-wordpress-next/blob/main/vendor/altcha-org/altcha/README.md Install the ALTCHA PHP library using Composer. ```sh composer require altcha-org/altcha ``` -------------------------------- ### Usage Example Source: https://github.com/altcha-org/altcha-wordpress-next/blob/main/vendor/altcha-org/altcha/README.md Demonstrates how to create, solve, and verify an ALTCHA challenge using the PHP library. ```php createChallenge(new CreateChallengeOptions( algorithm: $pbkdf2, cost: 5000, counter: random_int(5000, 10000), expiresAt: time() + 600, )); // Solve the challenge (client-side in production) $solution = $altcha->solveChallenge(new SolveChallengeOptions( algorithm: $pbkdf2, challenge: $challenge, )); // Verify the solution (server-side) if ($solution !== null) { $payload = new Payload($challenge, $solution); $result = $altcha->verifySolution(new VerifySolutionOptions( algorithm: $pbkdf2, payload: $payload, )); if ($result->verified) { echo "Solution verified!\n"; } } ``` -------------------------------- ### Scrypt Algorithm Initialization Source: https://github.com/altcha-org/altcha-wordpress-next/blob/main/vendor/altcha-org/altcha/README.md Example of initializing the Scrypt algorithm. ```php use AltchaOrg\Altcha\Algorithm\Scrypt; new Scrypt(); ``` -------------------------------- ### Payload Serialization Source: https://github.com/altcha-org/altcha-wordpress-next/blob/main/vendor/altcha-org/altcha/README.md Examples of serializing a Payload object. ```php $payload = new Payload($challenge, $solution); $payload->toArray(); // array $payload->toJson(); // JSON string $payload->toBase64(); // base64-encoded JSON ``` -------------------------------- ### Verifying Specific Form Fields Hash Source: https://github.com/altcha-org/altcha-wordpress-next/blob/main/vendor/altcha-org/altcha/README.md Example of verifying the hash of specific form fields. ```php $isValid = ServerSignature::verifyFieldsHash( formData: ['name' => 'John', 'email' => 'john@example.com'], fields: ['name', 'email'], fieldsHash: hash('sha256', "John\njohn@example.com"), ); ``` -------------------------------- ### Server Signature Verification Source: https://github.com/altcha-org/altcha-wordpress-next/blob/main/vendor/altcha-org/altcha/README.md Example of verifying a server signature payload and accessing verification data. ```php use AltchaOrg\Altcha\ServerSignature; $result = ServerSignature::verifyServerSignature($payload, 'server-secret'); if ($result->verified) { $result->verificationData->expire; // int $result->verificationData->score; // float $result->verificationData->verified; // bool $result->verificationData->fields; // array $result->verificationData->classification; // string $result->verificationData['email']; // array access also works } ``` -------------------------------- ### Running Tests Source: https://github.com/altcha-org/altcha-wordpress-next/blob/main/vendor/altcha-org/altcha/README.md Command to run the project's tests. ```sh vendor/bin/phpunit tests ``` -------------------------------- ### Argon2id Algorithm Initialization Source: https://github.com/altcha-org/altcha-wordpress-next/blob/main/vendor/altcha-org/altcha/README.md Instantiate the Argon2id algorithm. Requires ext-sodium. ```php use AltchaOrg\Altcha\Algorithm\Argon2id; new Argon2id(); ``` -------------------------------- ### Run E2E Tests Source: https://github.com/altcha-org/altcha-wordpress-next/blob/main/e2e/README.md Command to execute the End-to-End tests. ```sh npm test ``` -------------------------------- ### PBKDF2 Algorithm Initialization Source: https://github.com/altcha-org/altcha-wordpress-next/blob/main/vendor/altcha-org/altcha/README.md Instantiate the PBKDF2 algorithm with different HMAC algorithms. ```php use AltchaOrg\Altcha\Algorithm\Pbkdf2; use AltchaOrg\Altcha\HmacAlgorithm; new Pbkdf2(); // PBKDF2/SHA-256 new Pbkdf2(HmacAlgorithm::SHA384); // PBKDF2/SHA-384 new Pbkdf2(HmacAlgorithm::SHA512); // PBKDF2/SHA-512 ``` -------------------------------- ### Altcha Class Initialization Source: https://github.com/altcha-org/altcha-wordpress-next/blob/main/vendor/altcha-org/altcha/README.md Initialize the Altcha class with secret keys and optional HMAC algorithm. ```php $altcha = new Altcha( hmacSignatureSecret: 'secret', hmacKeySignatureSecret: 'key-secret', // enables fast verification path hmacAlgorithm: HmacAlgorithm::SHA256, // default ); ``` -------------------------------- ### PGP Key for Encrypted Reports Source: https://github.com/altcha-org/altcha-wordpress-next/blob/main/SECURITY.md Recommended for encrypting security reports to ensure confidentiality. ```text https://altcha.org/pgp/security-public-key.asc ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.