#native_company# #native_desc#

Customizable Random Password Generator

By Blake Caldwell
on June 5, 2001

Version: 2.0

Type: Function

Category: Algorithms

License: GNU General Public License

Description: Random password generator that you can customize to include uppcase letters, lowercase letters, and numbers, as well as the length of the password. Read the comments for more info.

# return a randomly-generated string with input length
# Blake Caldwell <[email protected]>
function randomString($length=15){
	static $srand;
	if($srand != true){
		$srand = true;
		srand((double)microtime()*1000000);		# only seed once!
	$chars = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
	for($i=0; $i<$length; $i++){
		$result .= substr($chars,rand(0,strlen($chars)-1),1);
	return $result;