Thanks for you reactions people, i have found the solution

Best regards,

Davy Obdam

Met vriendelijke groeten uit Den Haag;-)

Daniel Beulshausen wrote:

At 11:45 17.06.2003 +0200, Davy Obdam wrote:

Hi people,

I have to make a password generator, but i have a little problem.

- It needs to generate password 8 characters long, and including 1 or 2 special characters(like #$%&*@).
- Those special characters can never appear as the first or last character in the string... anywhere between is fine.


I have a password generator script now that does the first thing... but the special character can be in front or back of the string wich it shouldnt.. i have been looking on the web for this but i havent found the answer. Below is my scripts so far..
Any help is appreciated, thanks for your time,


please don't cross-post.

>>>
<?php
function generatePassword( $length = 8 ) {
$alphaNumChar = array( 'a','b','c','d','e','f','g','h','e','f','g','h','i','j','k',
'l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','0','1','2','3','4','5','6',
'7','8','9' );
$specialChar = array( '%','#','*','&' );
$allChars = array_merge( $alphaNumChar, $specialChar );


$returnValue = '';

        mt_srand( lcg_value() * 10000 + time() );
        $returnValue .= $alphaNumChar[ array_rand( $alphaNumChar ) ];

if( ( $length -= 2 ) > 0 ) {
while( $length-- > 0 ) {
$returnValue .= $allChars[ array_rand( $allChars ) ];
}
}


        $returnValue .= $alphaNumChar[ array_rand( $alphaNumChar ) ];
        return $returnValue;
}

echo generatePassword();
?>
<<<

mit freundlichen grüßen aus berlin,
daniel

/*--
Daniel Beulshausen - [EMAIL PROTECTED]
Using PHP on Windows? http://www.php4win.com


--
-----------------------------------------------------------------------
Davy Obdam Web application developer


Networking4all
email: [EMAIL PROTECTED]
email: [EMAIL PROTECTED]
internet: http://www.networking4all.com
-----------------------------------------------------------------------




-- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to