note 84995 deleted from function.rand by bjori

From: Date: Sat, 09 Aug 2008 17:16:05 +0000
Subject: note 84995 deleted from function.rand by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-143326@lists.php.net to get a copy of this message
Note Submitter: Jase Taylor Reason: useless ---- A quick correction on my last post There is a way to make my method even faster After reading through the older comments on this page, i noticed the post by relsqui at armory dot com on 21-Jan-2005 02:23 about using bitwise operations This makes my function even faster Instead of a process time of 0.00065 average, using bitwise operations has dropped this down to 0.00051 average. This is based on creating a 50 character password to be more realistic, creating a 10 character password takes 0.000013269286 on average (average gained from 1,000,000 executions) function pass_gen($pass_length) { $str = '012345679abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $pass = ''; $str_len = strlen($str) -1; for($i=0; $i < $pass_length; $i++) { $rand = mt_rand()&$str_len; $pass .=$str[$rand]; } return $pass; }

« previous php.notes (#143326) next »