diff --git a/fp_altcha_spamschutz/src/Vendor/AltchaOrg/Altcha/V1/ChallengeOptions.php b/fp_altcha_spamschutz/src/Vendor/AltchaOrg/Altcha/V1/ChallengeOptions.php new file mode 100644 index 0000000..703188c --- /dev/null +++ b/fp_altcha_spamschutz/src/Vendor/AltchaOrg/Altcha/V1/ChallengeOptions.php @@ -0,0 +1,53 @@ + $saltLength Length of the random salt (default: 12 bytes). + */ + public function __construct( + Algorithm $algorithm = Algorithm::SHA256, + int $maxNumber = self::DEFAULT_MAX_NUMBER, + ?\DateTimeInterface $expires = null, + array $params = [], + int $saltLength = self::DEFAULT_SALT_LENGTH, + ) { + parent::__construct( + $algorithm, + $maxNumber, + $expires, + bin2hex(self::randomBytes($saltLength)), + self::randomInt($maxNumber), + $params + ); + } + + private static function randomInt(int $max): int + { + return random_int(0, $max); + } + + /** + * @param int<1, max> $length + */ + private static function randomBytes(int $length): string + { + return random_bytes($length); + } +}