May
3
PHP Random Password Generation
May 3, 2008 |
A random password generator is a fairly common function used by PHP coded websites. The one below is what i use for many websites.
<?php
/**
* Random Password Generator
* @public
* @param int $length Length of password to generate
* @return string Returns randomised password
*/
function randomPword($length)
{
$seed = 'ABC123DEF456GHI789JKL0MNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
$seedLength = strlen($seed);
$random = '';
for ($i=1; $i <= $length; $i++)
{
$charPos = mt_rand(0, ($seedLength - 1));
$singleChar = substr($seed, $charPos, 1);
$random .= $singleChar;
}
return $random;
}
?>
Hope it helps! Enjoy!
Similar Posts
- PHP - Display all jpg Image Infomation
- Wordpress Mail Localhost
- PHP eval is evil
- Backup Export MySQL Database Using PHP
- PHP Find Absolute Path
- Use Adsense for Search on WordPress
- PHP cURL XAMPP
- Troubleshoot Flash PHP Can’t Upload Flv
Comments
1 Comment so far



































[...] php, generar password aleatorio [...]