note 43110 added to function.rand

From: Date: Wed, 09 Jun 2004 21:54:39 +0000
Subject: note 43110 added to function.rand
Groups: php.notes 
Request: Send a blank email to php-notes+get-70618@lists.php.net to get a copy of this message
Here is a quick and easy way to generate a random password. This was taught to me by a friend and I feel that it is a rather creative way to creat a random password with a mix of letters and numbers. <?php $rand = rand(1, 999999999); //random number 1-999999999 $md5string= md5($rand); //create md5 of random number $string = substr($md5hash, 0, 10); //cut the hash to 10 characters $newpass = $string; // 10 digit random password of numbers nad letters $md5_newpass = md5($newpass); //create md5 for updating user account in database. ?> As you can see, it md5 encrypts a random number in order to get a random combination of numbers and letters. The substr() function is then used to cut the md5 hash from 30 to 10 characters. This is a quick, easy, creative, and secure way to create a random password. ---- Manual Page -- http://www.php.net/manual/en/function.rand.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+43110 Delete -- http://master.php.net/manage/user-notes.php?action=delete+43110&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+43110&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#70618) next »