#native_company# #native_desc#
#native_cta#

The Smartest way to generate random passwords

By Walid Karray
on October 7, 2009

Version: 1

Type: Function

Category: Algorithms

License: GNU General Public License

Description: Generate random password from a set of chars ($pool)

	/*
	 * Generate random password from a set of chars ($pool)
	 * 
	 * @param	integer	$len	Password length
	 * @return	string	Rand password
	 */
	private function generateRandomPasswd($len = 10) {
		$string = '';
		$pool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
		for($i = 1; $i <= $len; $i ++) {
			$string .= substr ( $pool, rand ( 0, 61 ), 1 );
		}
		
		return $string;
	}