note 78235 added to function.mt-rand

From: Date: Wed, 03 Oct 2007 21:49:29 +0000
Subject: note 78235 added to function.mt-rand
Groups: php.notes 
Request: Send a blank email to php-notes+get-131049@lists.php.net to get a copy of this message
If you want some random text that is more secure than what can get from a built in PHP method, you can simply do: $myRandomText = shell_exec('head -c 128 < /dev/urandom'); That will get around the fact that rand() and mt_rand() are a bad place to start generating something that is supposed to be cryptographically secure. The only down sides to this that I see are: a) Ugly b) Slow (have to launch external processes) c) Not portable (can't do this on Windows) But if you can live with that, this will be much more secure than using rand() or mt_rand(). - Brad ---- Server IP: 64.71.164.2 Probable Submitter: 205.227.165.244 ---- Manual Page -- http://www.php.net/manual/en/function.mt-rand.php Edit -- https://master.php.net/note/edit/78235 Del: integrated -- https://master.php.net/note/delete/78235/integrated Del: useless -- https://master.php.net/note/delete/78235/useless Del: bad code -- https://master.php.net/note/delete/78235/bad+code Del: spam -- https://master.php.net/note/delete/78235/spam Del: non-english -- https://master.php.net/note/delete/78235/non-english Del: in docs -- https://master.php.net/note/delete/78235/in+docs Del: other reasons-- https://master.php.net/note/delete/78235 Reject -- https://master.php.net/note/reject/78235 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#131049) next »