# defender-security/6.2.0/src/component/altcha/class-challenge-options.php

Defender Security – Malware Scanner, Login Security &amp; Firewall, version 6.2.0. 50 lines.

- Page: https://pluginprobe.com/plugins/defender-security/6.2.0/code/src/component/altcha/class-challenge-options.php
- Raw: https://pluginprobe.com/plugins/defender-security/6.2.0/raw/src/component/altcha/class-challenge-options.php
- Modified: 2026-02-02T07:00:22+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/defender-security/6.2.0/code/src/component/altcha/class-challenge-options.php#L10-L20`.

```php
<?php
/**
 * Class Challenge_Options
 *
 * @package WP_Defender\Component\Altcha
 */

namespace WP_Defender\Component\Altcha;

use WP_Defender\Component\Altcha\Hasher\Algorithm;
use WP_Defender\Component\Crypt;

/**
 * Class Challenge_Options.
 *
 * @phpstan-import-type ChallengeParams from Base_Challenge_Options
 */
class Challenge_Options extends Base_Challenge_Options {
	private const DEFAULT_SALT_LENGTH = 12;

	/**
	 * Options for creation of a new challenge with sane defaults.
	 *
	 * @param string                  $algorithm  Hashing algorithm to use (`SHA-1`, `SHA-256`, `SHA-512`, default:
	 *                                            `SHA-256`).
	 * @param int                     $max_number  Maximum number for the random number generator (default: 1,000,000).
	 * @param null|\DateTimeInterface $expires    Optional expiration time for the challenge.
	 * @param array                   $params     Optional URL-encoded query parameters.
	 * @param int                     $salt_length Length of the random salt (default: 12 bytes).
	 */
	public function __construct(
		string $algorithm = Algorithm::SHA256,
		int $max_number = self::DEFAULT_MAX_NUMBER,
		?\DateTimeInterface $expires = null,
		array $params = array(),
		int $salt_length = self::DEFAULT_SALT_LENGTH
	) {
		$salt_length = max( self::DEFAULT_SALT_LENGTH, $salt_length );

		parent::__construct(
			$algorithm,
			$max_number,
			$expires,
			bin2hex( Crypt::random_bytes( $salt_length ) ),
			Crypt::random_int( 0, $max_number ),
			$params
		);
	}
}

```
