note 114128 added to class.thread

From: Date: Tue, 14 Jan 2014 11:00:34 +0000
Subject: note 114128 added to class.thread
Groups: php.notes 
Request: Send a blank email to php-notes+get-198231@lists.php.net to get a copy of this message
/* 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é... ---- Server IP: 72.52.91.14 Probable Submitter: 72.52.91.14 ---- Manual Page -- http://php.net/manual/en/class.thread.php Edit -- https://master.php.net/note/edit/114128 Del: integrated -- https://master.php.net/note/delete/114128/integrated Del: useless -- https://master.php.net/note/delete/114128/useless Del: bad code -- https://master.php.net/note/delete/114128/bad+code Del: spam -- https://master.php.net/note/delete/114128/spam Del: non-english -- https://master.php.net/note/delete/114128/non-english Del: in docs -- https://master.php.net/note/delete/114128/in+docs Del: other reasons-- https://master.php.net/note/delete/114128 Reject -- https://master.php.net/note/reject/114128 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#198231) next »