note 114128 deleted from class.thread by salathe

From: Date: Tue, 02 Aug 2016 12:14:43 +0000
Subject: note 114128 deleted from class.thread by salathe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-206189@lists.php.net to get a copy of this message
Note Submitter: hanscastroadmn at gmail dot com ---- /* Programa para generar diccionarios de fuerza bruta con diferentes hilos usando Thread en PHP 5.4 */ class FuerzaBruta extends Thread { private $n; private $out; private $smap; public function FuerzaBruta($numero) { $this->n = $numero; // Numero de caracteres $this->smap = ['a','b','c','d']; $this->start(); } public function run(){ for($i = 0; $i < pow(count($this->smap), $this->n) - 1; $i++){ $this->visualizar(); $this->siguiente(); } $this->visualizar(); } public function siguiente(){ $this->out[0]++; $m = 0; while($this->out[$m] == count($this->smap)){ $this->out[$m++] = 0; $this->out[$m]++; } } public function visualizar(){ $output = ""; for($i = 0;$i < $this->n; $i++){ $output += $this->smap[$this->out[$i]]; } echo $output; } } //Genera todas las combinaciones de 5 caracteres. for($i = 1; $i < 5; $i++) new FuerzaBruta($i); // Algún error tendré...

« previous php.notes (#206189) next »