Генератор паролей - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of Генератор паролей.php
- <?php
- function passgen($length, $count) {
- $arrKeys = [
- 'a', 'b', 'c', 'd', 'e', 'f',
- 'g', 'h', 'i', 'j', 'k', 'l',
- 'm', 'n', 'o', 'p', 'q', 'r',
- 's', 't', 'u', 'v', 'w', 'x',
- 'y', 'z', 'A', 'B', 'C', 'D',
- 'E', 'F', 'G', 'H', 'I', 'J',
- 'K', 'L', 'M', 'N', 'O', 'P',
- 'Q', 'R', 'S', 'T', 'U', 'V',
- 'W', 'X', 'Y', 'Z', '1', '2',
- '3', '4', '5', '6', '7', '8',
- '9', '0'
- ];
- for ($c = 1; $c < $count + 1; $c++) { //счет количества генерируемых паролей
- $pass = '';//обнуляем переменную после каждой итерации
- for ($l = 0; $l < $length; $l++) { //счет количества символов в пароле
- $pass .= $arrKeys[mt_rand(0, count($arrKeys) - 1)];//формируем пароль из рандомных элементов массива с возможными символами
- }
- echo $c.'. '.$pass.'<br>';//вывод полученного пароля с номерацией в начале
- }
- }
- echo passgen(10, 5);