Skip to content

Instantly share code, notes, and snippets.

@antimech
Last active November 14, 2023 06:55
Show Gist options
  • Save antimech/c42e775e44edfaec62be8eccd829d456 to your computer and use it in GitHub Desktop.
Save antimech/c42e775e44edfaec62be8eccd829d456 to your computer and use it in GitHub Desktop.
Этот скрипт генерирует капчу которую сложно спутать с кирилицей и цифрами
#!/usr/bin/env php8.1
<?php
const CAPTCHA_LENGTH = 6;
$captchaSymbolsWhitelist = [
'I', 'U', 'Y', 'D', 'F', 'G', 'J', 'L', 'N', 'Q', 'R', 'S', 'V', 'W', 'Z',
'2', '3', '4', '5', '6', '7', '8', '9',
];
$whitelistLength = sizeof($captchaSymbolsWhitelist);
$captchaString = '';
for ($i = 0; $i < CAPTCHA_LENGTH; $i++) {
$rand = random_int(0, $whitelistLength - 1);
$captchaString .= $captchaSymbolsWhitelist[$rand];
}
echo $captchaString;
echo PHP_EOL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment