Генератор паролей - 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.

Name: Генератор паролей fullscreencopydownloadembedprint


Your result can be seen below.

Result of php executing





Full code of Генератор паролей.php

  1. <?php
  2. function passgen($length, $count) {
  3.     $arrKeys = [
  4.         'a', 'b', 'c', 'd', 'e', 'f',
  5.         'g', 'h', 'i', 'j', 'k', 'l',
  6.         'm', 'n', 'o', 'p', 'q', 'r',
  7.         's', 't', 'u', 'v', 'w', 'x',
  8.         'y', 'z', 'A', 'B', 'C', 'D',
  9.         'E', 'F', 'G', 'H', 'I', 'J',
  10.         'K', 'L', 'M', 'N', 'O', 'P',
  11.         'Q', 'R', 'S', 'T', 'U', 'V',
  12.         'W', 'X', 'Y', 'Z', '1', '2',
  13.         '3', '4', '5', '6', '7', '8',
  14.         '9', '0'
  15.     ];
  16.  
  17.         for ($c = 1; $c < $count + 1; $c++) { //счет количества генерируемых паролей
  18.                 $pass = '';//обнуляем переменную после каждой итерации
  19.                 for ($l = 0; $l < $length; $l++) { //счет количества символов в пароле
  20.                         $pass .= $arrKeys[mt_rand(0, count($arrKeys) - 1)];//формируем пароль из рандомных элементов массива с возможными символами
  21.         }
  22.                 echo $c.'. '.$pass.'<br>';//вывод полученного пароля с номерацией в начале
  23.     }
  24.  
  25. }
  26. echo passgen(10, 5);
File Description
  • Генератор паролей
  • PHP Code
  • 25 Apr-2022
  • 1.09 Kb
You can Share it: