length = $length; } public function generate(): string { try { return substr(bin2hex(random_bytes((int)ceil($this->length / 2))), 0, $this->length); } catch (Exception $exception) { throw SecretKeyGenerationException::create($exception); } } }