protected function generatePrivateKeyFile()
{
$captchaScript = $this->getCaptchaScriptFile();
$path = dirname($this->getApplication()->getAssetManager()->getPublishedPath($captchaScript));
$fileName = $path . DIRECTORY_SEPARATOR . 'captcha_key.php';
if (!is_file($fileName)) {
@mkdir($path);
$key = $this->generateRandomKey();
$content = "<?php\n\$privateKey='{$key}';\n?>";
file_put_contents($fileName, $content);
}
return $fileName;
}