• 11th, Jun 2010

PHP Security Functions

/**
* Security Functions
* www.unexpectedit.com
*/
//UID generate unique random number/letters or a random password
function generateUID($length=32) {
	$pass="";
	for($k=0; $k < $length; $k++) {
		$prob = mt_rand(1,10);
		if($prob <= 3) // A-Z probability: 30%
			$pass .=  chr(mt_rand(65,90));
		if($prob <= 6 )   //a-z probability is 30%
			$pass .= chr(mt_rand(97,122));
		else //0-9 probability is 40%
			$pass .= chr(mt_rand(48, 57));
	}
	return $pass;
}

Tags: , , , , ,

Leave a Reply

*

© 2010 unexpected[it]. All Rights Reserved.