<?php
include_once('data.php');
 
function readValue()
{
    return intval(trim(fgets(STDIN)));
}

function writeValue($value)
{
    return echo $value . PHP_EOL;
}

function generatePass(int $length, string $characters):string
{
    $arrayChar = explode(',',$characters);

    $newArrayPass=[];
    
    for ($i=0;$i < $length;$i++ ) {
    
      $indiceArray = random_int(0,(count($arrayChar)-1));
    
      $newArrayPass[$i]=$arrayChar[$indiceArray];
    
   }
    return implode('',$newArrayPass);
}


$length = readValue();

$pass = generatePass($length,$characters);

writeValue($pass);

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: